[osg-users] imageio problems and possible solutions on loading some PNG images.

Tatsuhiro Nishioka tat.fgmacosx at gmail.com
Thu Nov 26 10:09:20 PST 2009


Hi Robert and Stephan,

I can see the problem using osgviewer.
The images I use are available from:
http://cvs.flightgear.org/viewvc/data/Textures/Sky/


Here I list some images that show the problems:

[Black Edges instead of transparency]
broken_n.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
cirrus_n.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
cl_cb.png: PNG image data, 512 x 512, 8-bit/color RGBA, non-interlaced
cl_cu.png: PNG image data, 1024 x 512, 8-bit/color RGBA, non-interlaced
cl_cu2.png: PNG image data, 512 x 256, 8-bit/color RGBA, non-interlaced
cl_cumulus.png: PNG image data, 1024 x 1024, 8-bit/color RGBA, non-interlaced
cl_ns.png: PNG image data, 1024 x 1024, 8-bit/color RGBA, non-interlaced
cl_ns_white.png: PNG image data, 1024 x 1024, 8-bit/color RGBA, non-interlaced
cl_stratus.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
cloud.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
few_n.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
inner_halo.png: PNG image data, 64 x 64, 8-bit/color RGBA, non-interlaced
moon.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
outer_halo.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
scattered_n.png: PNG image data, 256 x 256, 8-bit/color RGBA, non-interlaced
sun.png: PNG image data, 128 x 128, 8-bit/color RGBA, non-interlaced

[CGBitmapContextCreate got error]
broken.png: PNG image data, 256 x 256, 8-bit gray+alpha, non-interlaced
cirrus.png: PNG image data, 256 x 256, 8-bit gray+alpha, non-interlaced
cl_cumulus2.png: PNG image data, 1024 x 1024, 8-bit gray+alpha, non-interlaced
cl_st.png: PNG image data, 256 x 256, 8-bit gray+alpha, non-interlaced
few.png: PNG image data, 256 x 256, 8-bit gray+alpha, non-interlaced
scattered.png: PNG image data, 256 x 256, 8-bit gray+alpha, non-interlaced


Stephan, 
I tried kCGImageAlphaFirst as you said, but it only showed the following errors on loading RGBA images (e.g. cl_cumulus.png):
<Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component colorspace; kCGImageAlphaFirst; 4096 bytes/row.
<Error>: CGContextDrawImage: invalid context

Could you make some tests with these images on your end too?

Best,
Tat

On Nov 26, 2009, at 11:07 PM, Robert Osfield wrote:

> HI Tat,
>
> I don't have a OSX system to test against personally, but for those
> who do have OSX and wish to help investigate this bug with the imageio
> plugin it would be worth putting together a small set of test images
> that you see problems so that they can reproduce the problem
> themselves.
>
> Also if we can settle upon an existing OSG example or a small mod to
> one that can help illustrate the issue then this would also help.  For
> instance do you see the problem if you do something as simple as:
>
>  osgviewer --image myimage.png
>
> Cheers,
> Robert.
>
> On Thu, Nov 26, 2009 at 1:12 PM, Tatsuhiro Nishioka
> <tat.fgmacosx at gmail.com> wrote:
>> Hi there,
>>
>> I have two problems in drawing PNG image using imageio on Mac OS X.
>>
>> One problem is that 16-bit grayscale textures (PNG images) cannot be loaded due to the following errors:
>>
>> <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 16 bits/pixel; 1-component colorspace; kCGImageAlphaLast; 512 bytes/row.
>> <Error>: CGContextDrawImage: invalid context
>>
>> The cause of this is that CGBitmapContextCreate doesn't accept the combination of 1 component colorspace and 16bps. One solution I can think of at this moment is to create a bitmap context using RGBA colorspace (as the same as the 32bit RGBA image). This works fine on FlightGear but I'm not so sure if this works on all 16bpp images.
>>
>>
>> Another problem is that imageio's libpng doesn't properly handle transparency in PNG file. The problem I have is that the transparency in PNG files are not at all handled and we see a lot of unexpected black or dark portions.  I strongly recommend the use of osgdb_png.so (or .dylib) for handling png images instead of imageio.
>>
>> More detail explanation, screenshots, and an experimental patch for solving these two problems are available from:
>> http://macflightgear.sourceforge.net/home/development-notes/devnote-nov-26-2009
>> Please try my patch and see if it also works on many OSG applications.
>>
>> FYI, I'm using OSG/svn as of a few day back on Mac OS 10.5.8 / intel.
>>
>> Best,
>>
>> Tat
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



More information about the osg-users mailing list