LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SavePanelDisplayToFile

SavePanelDisplayToFile() Function is working OK but saved .PNG file is not in 256 color resolution.

How is the process of changing the setting of the color resolution to 24 to 256. 

Thank you for the Help.

0 Kudos
Message 1 of 3
(3,314 Views)

Regardless the extension that you give to the file, SavePanelDisplayToFile produces a bitmap object and creates a bitmap file on disk, not a png one. You can check it looking into the code for the function in toolbox.c file: first of all the function obtains the bitmap object form the panel, next saves it to file. Now, it seems to me that bitmaps in CVI always follow the rule stated in on line help for PixelDepth field in NewBitmap function:

Regardless of the color depth that you specify, the new bitmap matches the color depth of the display screen.

Now, if you cannot reduce your screen color depth ancd indeed you want to obtain a smaller resolution you should run into the process or mapping 24bits into 8bits colors, or find a library that does this for you, next save the bitmap to file. It may not be the easiest thing of all...

Finally, you may find useful to use new SaveBitmapToXXXFile in the User Interface library, which permits you to create true PNG or JPEG files instead of BMP ones, but I'm afraid you will have the same limitations as of color depth since all these functions rely on bitmaps.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(3,303 Views)
Hi,

Roberto is right, you cannot create a PNG directly using SavePanelDisplayToFile. Giving it the PNG extension may make Windows think it is a PNG, but it is still a BMP (simply open the file in Paint and resave it as a PNG to see that the file is different). As Roberto said, you will have to save the BMP and then use the SaveBitmapToPNGFile function to convert it to a true PNG.

Unfortunately, as Roberto said, you are limited to bitmap creation rules. To increase your resolution you will need to follow the instruction described in the New Bitmap function in the CVI help.

It sounds like you have are not having trouble using the SavePanelDisplayToFile function itself, however, if you would like to see an NI example, you can look at Programmatic Bitmap Save in CVI

Matt Mueller
NI
0 Kudos
Message 3 of 3
(3,285 Views)