I cannot seem to load a 2 colour bmp file, code is
Var f As New FolderItem(“3.bmp”, FolderItem.PathModes.Native)
Var pic as picture
If f <> Nil And f.Exists Then
pic=picture.Open(f)
end if
pic.Graphics.DrawText(“test”,40,40,100)
Var ff As New FolderItem(“4.bmp”, FolderItem.PathModes.Native)
// Save the image out to the file
pic.Save(ff, Picture.Formats.BMP)
I am trying to load write some text on it and save it. But I get a NOE on pic=picture.Open(f) the file exists and is a valid 2 colour bmp?
Xojo hasn’t supported 2 color pictures for many years, annoyingly.
BUT: check whether pic is nil after the Open() statement
if it is not,
Create a new picture in memory, and draw pic to it
dim pic2 as new picture (pic.width,pic.height)
pic2.drawpicture pic,0,0
pic2.Graphics.DrawText("test",40,40,100)
problem is, the pi paper white screen wont read a png it needs a 2 colour bmp, and unless I use some third party plugin there is no way to get it in and out of Xojo
Is the original one compressed?
If it is not, the 2-color image will be represented in the file as a fairly simple byte array.
if you create a picture in memory of the right size, and draw text on that, you MIGHT succeed in loading the BMP into memory, then setting bytes of the image array, based on the color of pixels in your rendered picture.
For example, the first few bytes of a BMP file should be:
2bytes : holds 'BM'
4bytes: ignore
4bytes: ignore
4bytes: start of the pixel array in the file /memoryblock