8-bit graphic formats

wolfgang

Member
Licensed User
Hi,
when I try to load an 8-bit graphic format (gif or bmp), I get the attached error message (PC). This happens only, when I want to draw with drawer.New2 (ImageList1.Item (0), B4PObject (5)) on this image. No problems with 24-bit formats.
 

Attachments

wolfgang

Member
Licensed User
Hi Erel,
here it is. It's 8-bit bmp with 256 colors.
 

agraham

Expert
Licensed User
It seems there is a GDI+ Graphics limitation - From MSDN

"Note You can only create Graphics objects from non-indexed .bmp files, such as 16-bit, 24-bit, and 32-bit .bmp files. Each pixel of non-indexed .bmp files holds a color, in contrast to pixels of indexed .bmp files, which hold an index to a color table."
 

wolfgang

Member
Licensed User
That's exactly what the error message says. And it's the same with a gif file.
 

klaus

Expert
Licensed User
Hi wolfgang
How do you load your image ?
In my program to display maps I load the image files in an ImageList object, and I had no problem loading your image.
You can look at it in:
http://www.basic4ppc.com/forum/showthread.php?t=1612

Best regards
Klaus
Switzerland
 

wolfgang

Member
Licensed User
Hi,
thank you all. The good news: This happens only on desktop. On PPC is no error.

The problem is not, that I can’t do this.The problem was that I want to save memory on PPC. But I found, that it doesn’t matter if you load the same file as a bmp (24-bit), jpg or a gif. In comparison to the desktop where the gif files are much smaller in RAM. On my device (ASUS 632N WM5) a 6 MB bmp or the same file as an 800 KB gif takes about 4 MB of memory(?!). But there is still a difference: bmp files can be loaded up to a size of ~ 1700 x 1700 pixels and gif files much bigger e.g. 2400 x 1800 pixels. I didn’t test the maximum.

@Klaus
wonderful software. But you don’t draw on your maps. Add an object named draw and this line of code:
B4X:
.
.
.
draw.New2 (ImageList1.Item (Map_I), B4PObject (5))
and you will get the same error message. I tested it. Again: wonderfull software.
 

agraham

Expert
Licensed User
The problem was that I want to save memory on PPC. But I found, that it doesn’t matter if you load the same file as a bmp (24-bit), jpg or a gif.
I'm afraid you can't save memory just by loading a different format. Jpg and gif are compressed formats for storing pictures in files. However pictures are always expanded to full bitmaps when loaded into memory no matter what the format of the source file.
 

wolfgang

Member
Licensed User
Hi agraham
I’m not sure if this is really correct. A gif is not only a compressed format, it’s color reduced too. I tested this with IrfanView on PC. A 6 MB bmp takes 6 MB in Ram and the same as a gif only 2 MB. My PPC is a 65536 (16 bit) color system. When I load a bmp or a jpg file in my device it will be reduced from 24 bit to 16 bit and the gif will be expanded from 8 bit to 16 bit. This could be the reason for all my maps take the same memory. I’m not really sure but this seems to be an explanation.
 

agraham

Expert
Licensed User
I’m not sure if this is really correct. A gif is not only a compressed format, it’s color reduced too.
There are several different sorts of memory bitmap format depending upon the colour depth of the image and whether its utilises a colour palette or not. Not surprisingly the desktop supports more formats than the device.

Maybe I misunderstood your post but the point I was making was that compression in the file does not translate to less memory when loaded. It is the image format of the picture that determines the memory used, not the type of file in which it is stored, although some file formats are restricted in the image formats they can accept.

As you have found out the Windows GDI+ graphics routines (a Drawer object)cannot handle palettised bitmaps - they have to be expanded to a minimum of a 24 bit colour bitmap in order to be manipulated so occupying more memory.
 
Top