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
Var ff As New FolderItem(“4.bmp”, FolderItem.PathModes.Native)
// Save the image out to the file
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?
Anyone any ideas?
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)
Than save pic2
Its to update a paperwhite display on pi, so it needs to be 2 col! Shame, was hoping there would be a solution to this.
I can open a 2 color bmp here in windows, not sure about pi, maybe someone can check who has one set up and running?
Is this a console app on the pi ?
But have you tried the code above?
Is pic nil immediately after the picture.open() or not?
Try converting the original image from BMP to PNG.
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: start of the pixel array in the file /memoryblock