2012年3月23日金曜日

ooo basic (libreoffice basic) でbitmap画像作成



以下みたいな感じで256 * 256ピクセルのbitmap画像が作成できた。
内容は泥臭いバイナリ処理だけど、RGBデータの配列とかあるなら、Drawのマクロとか使うよりスマートかも。

Dim ci As Integer, cl As Long
sImagePath = "C:\Documents and Settings\ttani\My Documents\test2.bmp"

Open sImagePath For Binary As 1
   
Put 1, 1, "BM"
cl = 54 + 256 * 256 * 3 : Put 1, 3, cl
  ci = 0 : Put 1, 7, ci
  ci = 0 : Put 1, 9, ci
  cl = 54 : Put 1, 11, cl
 
  cl = 40 : Put 1, 15, cl
  cl = 256 : Put 1, 19, cl
  cl = 256 : Put 1, 23, cl
  ci = 1 : Put 1, 27, ci
  ci = 24 : Put 1, 29, ci
  cl = 0 : Put 1, 31, cl
  cl = 0 : Put 1, 35, cl
  cl = 0 : Put 1, 39, cl
  cl = 0 : Put 1, 43, cl
  cl = 0 : Put 1, 47, cl
  cl = 0 : Put 1, 51, cl

Dim aData(256 * 256 * 3) As Byte
Dim counter As Long

For i = 0 To 255
For j = 0 To 255
aData(counter) = i
counter = counter + 1
aData(counter) = j
counter = counter + 1
aData(counter) = 255
counter = counter + 1
Next j
Next i
 
For i = 0 To Ubound(aData()) - 1
ci = aData(i) : Put 1, 55 + i, ci
Next i
Close 1

0 件のコメント: