Author | Topic: Problem saving PNG files on Windows XP | |
---|---|---|
Andreas Gehrs-Pahl | Problem saving PNG files on Windows XP on Thu, 19 Feb 2015 09:50:54 -0500 Till, Saving bitmaps in the PNG format (in 2.0.570) on Windows XP will create invalid files that are missing most of the information, possibly because pixels are saved as being transparent? This works fine on Windows 7, though. The attached images were created with a simple routine to copy the active dialog to the clipboard, and getting the bitmap from there, basically using: oBitmap := oClipBoard:GetBuffer(XBPCLPBRD_BITMAP) They were then saved with 1.9.355 and with 2.0.570 using basically: oBitmap:SaveFile(cFileName, XBPBMP_FORMAT_PNG, nCompression) Changing the Compression value has no effect on this particular issue, and saving in BMP or JGP formats will result in normal files without the issue. I believe the problem started with 2.0.502, but I can't verify that right now. In 1.9.355 there was a problem with saving PNGs on Windows XP with a compression ratio greater than about 50% -- or the default value (-1) -- resulting in (empty) PNG files that were just 77-bytes long, but this seems to have been fixed in 2.0. Also, saving images in GIF format isn't working in either version and on any OS, always resulting in basically empty GIF87a files. I didn't find any existing PDRs for those issues. If you need more details or a working demo program, please let me know. Thanks, Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas.GP@Charter.net web: http://www.Aerospace-History.net Images.zip | |
Till Warweg | Re: Problem saving PNG files on Windows XP on Mon, 23 Feb 2015 16:27:03 +0100 Andreas, If I understand you correctly, NONE of the PNG or GIF files you save under XP? That is what I tried to reproduce in the first step. However, my test program seems to work fine on my XP SP2 system. Could you please try the simple program I've attached to this posting? If I didn't make a mistake somewhere, something must be different on our machines, or possibly in the input data Kind regards, Till Warweg [Alaska Software] -------------------------------------------------------------------- Technical Support: support@alaska-software.com News Server: news.alaska-software.com Homepage: http://www.alaska-software.com KnowledgeBase: http://www.alaska-software.com/kb -------------------------------------------------------------------- "Andreas Gehrs-Pahl" schrieb im Newsbeitrag news:cxpeckqospvv.1kggrgxp6l3ce$.dlg@40tude.net... > Till, > > Saving bitmaps in the PNG format (in 2.0.570) on Windows XP will create > invalid files that are missing most of the information, possibly because > pixels are saved as being transparent? This works fine on Windows 7, though. > > The attached images were created with a simple routine to copy the active > dialog to the clipboard, and getting the bitmap from there, basically using: > > oBitmap := oClipBoard:GetBuffer(XBPCLPBRD_BITMAP) > > They were then saved with 1.9.355 and with 2.0.570 using basically: > > oBitmap:SaveFile(cFileName, XBPBMP_FORMAT_PNG, nCompression) > > Changing the Compression value has no effect on this particular issue, and > saving in BMP or JGP formats will result in normal files without the issue. > I believe the problem started with 2.0.502, but I can't verify that right > now. > > In 1.9.355 there was a problem with saving PNGs on Windows XP with a > compression ratio greater than about 50% -- or the default value (-1) -- > resulting in (empty) PNG files that were just 77-bytes long, but this seems > to have been fixed in 2.0. > > Also, saving images in GIF format isn't working in either version and on any > OS, always resulting in basically empty GIF87a files. > > I didn't find any existing PDRs for those issues. If you need more details > or a working demo program, please let me know. > > Thanks, > > Andreas > -- > Andreas Gehrs-Pahl > Absolute Software, LLC > > phone: (989) 723-9927 > email: Andreas.GP@Charter.net > web: http://www.Aerospace-History.net test.zip | |
Andreas Gehrs-Pahl | Re: Problem saving PNG files on Windows XP on Mon, 23 Feb 2015 18:59:25 -0500 Till, >If I understand you correctly, NONE of the PNG or GIF files >you save under XP? That is what I tried to reproduce in the >first step. However, my test program seems to work fine >on my XP SP2 system. The difference is that you load a PNG file, before saving it again in a different format. This seems to work, as the XbpBitmap object seems to be initialized correctly that way. I have attached a demo program, based on the Alaska Software example program: "..\Source\Samples\basics\xbpstyle\static.prg", which has three buttons, one each to save the dialog in JPG, PNG and GIF format. The bitmap is created by the same code that I mentioned before: oBitmap := oClipBoard:GetBuffer(XBPCLPBRD_BITMAP) That apparently creates a bitmap that can only be successfully saved -- on Windows XP -- in the JPG format. On Windows 7, the PNG format works also, but the GIF format doesn't work on either. I hope this example will be more clear. Thanks, Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas.GP@Charter.net web: http://www.Aerospace-History.net BitmapTest.zip | |
Till Warweg | Re: Problem saving PNG files on Windows XP on Fri, 27 Feb 2015 18:44:20 +0100 Andreas, Thank you for the comprehensive example. I've done some tests on an XP system here, and I can confirm your findings. There seems to be a general problem converting 32 bit bitmaps to formats with lower pixel depths on Windows XP. 1.9 only supported 24 bit color depths (even on 32 bpp screens), and this limitation was lifted for 2.0. It might be a platform limitation, we need to investigate. Reducing the desktop's color depth in Control Panel (and hence your source image's) seems to make the problem go away. Saving GIFs seems to be flawed in this particular case even on modern OS's. I saw the same behavior under 1.9, so this seems to be a different issue. I'll create PDR's to document these findings. Are these problems urgent for you? Kind regards, Till Warweg [Alaska Software] -------------------------------------------------------------------- Technical Support: support@alaska-software.com News Server: news.alaska-software.com Homepage: http://www.alaska-software.com KnowledgeBase: http://www.alaska-software.com/kb -------------------------------------------------------------------- "Andreas Gehrs-Pahl" schrieb im Newsbeitrag news:10p451c3amreo$.16znml4lkrkox$.dlg@40tude.net... > Till, > >>If I understand you correctly, NONE of the PNG or GIF files >>you save under XP? That is what I tried to reproduce in the >>first step. However, my test program seems to work fine >>on my XP SP2 system. > > The difference is that you load a PNG file, before saving it again in a > different format. This seems to work, as the XbpBitmap object seems to be > initialized correctly that way. > > I have attached a demo program, based on the Alaska Software example > program: "..\Source\Samples\basics\xbpstyle\static.prg", which has three > buttons, one each to save the dialog in JPG, PNG and GIF format. The bitmap > is created by the same code that I mentioned before: > > oBitmap := oClipBoard:GetBuffer(XBPCLPBRD_BITMAP) > > That apparently creates a bitmap that can only be successfully saved -- on > Windows XP -- in the JPG format. On Windows 7, the PNG format works also, > but the GIF format doesn't work on either. > > I hope this example will be more clear. > > Thanks, > > Andreas > -- > Andreas Gehrs-Pahl > Absolute Software, LLC > > phone: (989) 723-9927 > email: Andreas.GP@Charter.net > web: http://www.Aerospace-History.net | |
Andreas Gehrs-Pahl | Re: Problem saving PNG files on Windows XP on Fri, 27 Feb 2015 14:33:13 -0500 Till, >I'll create PDR's to document these findings. Thanks. >Are these problems urgent for you? Not really. My workaround is to force the JPG format on Windows XP: #if XPPVER > 2000500 if val(OS(OS_VERSION)) < 6 .and. nSaveType == XBPBMP_FORMAT_PNG cExtension := 'JPG' nSaveType := XBPBMP_FORMAT_JPG endif #endif As JPG files (of screen shots) are considerably larger than PNG files, I wouldn't mind a different workaround that allows me to convert the bitmap some other way to 24 bits, before saving it. But I can live with the above workaround for now. Thanks, Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas.GP@Charter.net web: http://www.Aerospace-History.net | |
Thomas Braun | Re: Problem saving PNG files on Windows XP on Mon, 02 Mar 2015 09:46:37 +0100 Andreas Gehrs-Pahl wrote: > As JPG files (of screen shots) are considerably larger than PNG files Really? That does not match with my experience at all. When preparing pictures for web pages, I almost always use jpg because they are much smaller then their png counterparts...?! I just made a quick test with greenshot and the file size ratio between png and jpg was 8:1 Then I used IrfanView to re-save the png with maximum compression and it went down to 6.3:1 Even if I save the jpg with maximum quality, it still is considerably smaller -> 2.8:1 regards Thomas | |
Andreas Gehrs-Pahl | Re: Problem saving PNG files on Windows XP on Mon, 02 Mar 2015 05:14:06 -0500 Thomas, >> As JPG files (of screen shots) are considerably larger than PNG files >Really? >That does not match with my experience at all. PNG is 100% loss-less, as it uses zip compression, resulting in very clear graphics. Screen Shots -- meaning Dialog (Input) Screens -- that contain (relatively) large areas with a single color and other repetitive areas, are perfect for very good zip compression results. If you have photos with random pixels and many different colors, JPGs will give you a much better result, as it is a (more or less) lossy compression that interpolates pixels and only saves some of them. JPGs using an 80% compression ratio will have pretty good quality, but will usually be 50% to 200% larger in size than a PNG file, if you save a dialog screen shot. And if you have a black and white graphic (with just 2 bits for color), a GIF file will be usually smaller than either PNG or JPG. Of course all of this is "usually" and "in general" and not an absolute. But in my experience, saving a screen shot of my application in PNG format will result in the smallest file, while giving the best picture quality, unless it is a screen shot that (just) shows a photo, of course. Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas.GP@Charter.net web: http://www.Aerospace-History.net | |
Thomas Braun | Re: Problem saving PNG files on Windows XP on Tue, 03 Mar 2015 10:25:41 +0100 Andreas Gehrs-Pahl wrote: > Thomas, > >>> As JPG files (of screen shots) are considerably larger than PNG files >>Really? >>That does not match with my experience at all. > > PNG is 100% loss-less, as it uses zip compression, resulting in very clear > graphics. Screen Shots -- meaning Dialog (Input) Screens -- that contain > (relatively) large areas with a single color and other repetitive areas, > are perfect for very good zip compression results. well... that explains it, wasn't thinking about input dialogs, just read "screenshot", tried it myself. And since I have a more "photo"-like desktop image I got the results I got... regards Thomas |