0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LEDマトリクスパネルのPPMファイル生成(日本語RGB対応)

Last updated at Posted at 2020-08-17

RGBマトリクスに、引数文字とRGBでppmファイルを生成します。
(python3はまだ調整できず)
nodejsと組み合わせれば、Webインターフェースでリアルタイムで文字表示できます。

1.ライブラリインストール

apt install fonts-takao-mincho
apt install libjpeg-dev
pip install Pillow

makePpm.pl

# encoding:UTF-8
# -*- codinf:utf-8 -*-

import sys
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw

args = sys.argv
inText = args[1].decode('utf-8')

rgb = args[2].split(",")
list = list(map(int,rgb))

viewText = []
viewText.append( ((u"    ") + inText ,tuple(list)))
text = tuple(viewText)

font = ImageFont.truetype("/usr/share/fonts/truetype/takao-mincho/TakaoMincho.ttf", 16)
all_text = ""
for text_color_pair in text:
    t = text_color_pair[0]
    all_text = all_text + t

width, ignore = font.getsize(all_text)

im = Image.new("RGB", (width + 30, 16), "black")
draw = ImageDraw.Draw(im)

x = 0;
for text_color_pair in text:
    t = text_color_pair[0]
    c = text_color_pair[1]
    #print("t=" + t + " " + str(c) + " " + str(x))
    draw.text((x, 0), t, c, font=font)
    x = x + font.getsize(t)[0]

im.save("/var/tmp/text.ppm")

2.実行

python makePpm.pl 文字列 255,255,255

3.その他

参考にしたサイト
https://digirakuda.org/contents/report/products/raspberrypi/electric-bulletin-board/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?