inable to decode jpg images using skia on android

768 views
Skip to first unread message

swagat mishra

unread,
Jul 26, 2012, 4:38:06 PM7/26/12
to skia-d...@googlegroups.com
hi,
i have set up skia on android (api 15).
I am trying to decode a jpg image using the following code:
SkBitmap bitmap;
SkStream* stream = new SkFILEStream("testfile.jpg");
bool x = SkImageDecoder::DecodeFile("testfile.jpg", &bitmap);

however, skia is unable to decode the file and returns false for x. the same code works while decoding png or bmp files.
Is this a known bug for skia in android? is there any workaroudn for this issue?
Regards,
Swagat Mishra

Message has been deleted

Robert Phillips

unread,
Aug 7, 2012, 10:46:50 AM8/7/12
to skia-d...@googlegroups.com
Hi There,
Have you tried adding a call to force linking of the jpeg codec? The
cmykjpeg.cpp file has an example of how this is done. PNGs are handled
special by Android by defining the SK_ENABLE_LIBPNG in
SkImageDecoderFactory.cpp.

Rob

On Sat, Aug 4, 2012 at 1:17 PM, swagat mishra
<swagatmi...@gmail.com> wrote:
> waiting for replies on this...please help
> --
> You received this message because you are subscribed to the Google Groups
> "skia-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/skia-discuss/-/lFk_CoS7_CYJ.
> To post to this group, send email to skia-d...@googlegroups.com.
> To unsubscribe from this group, send email to
> skia-discuss...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/skia-discuss?hl=en.

swagat mishra

unread,
Aug 12, 2012, 7:27:32 PM8/12/12
to skia-d...@googlegroups.com
Hi,
I did the force linking and while debugging find that the right codec is being used and am able to step in to SkImageDecoder_libjpeg.cpp.
However , i am still unable to get a decoded jpeg.
Does this mean its a problem in libjpeg and not skia?
As an additional information ,
i stepped into libjpeg and went till jddctmgr.c and found that JDCT_IFAST_SUPPORTED is not defined and i think this could be a cause of the failing.
 
 

Jon C

unread,
Sep 20, 2012, 3:22:59 PM9/20/12
to skia-d...@googlegroups.com
I ran into the same problem, and it turns out that libjpeg by default (in jmorecfg.h) only defines DCT_ISLOW_SUPPORTED, and undef's DCT_IFAST* or DCT_FLOAT*.  However, in Skia, for SkImageDecoder_libjpeg.cpp, it sets cinfo.dct_method = JDCT_IFAST by default.  This is why currently, out of the box, it doesn't look like skia would be able to decode jpeg.  Setting cinfo.dct_method = JDCT_ISLOW (or presumably defining IFAST_SUPPORTED or FLOAT_SUPPORTED in jmorecfg.h) allowed it to work for me.

Anthony Catel

unread,
Sep 28, 2012, 8:47:23 AM9/28/12
to skia-d...@googlegroups.com
Same issue here.

The annoying thing is that DCT_I* macro are wrapper in JPEG_INTERNAL_OPTIONS which make skia impossible to #ifdef for the good value.

Setting it to ISLOW on SkImageDecode_libjpeg.cpp would be right choice IMHO.

Janez Zemva

unread,
Sep 28, 2012, 9:02:46 AM9/28/12
to skia-d...@googlegroups.com
Just use something else, I recommend:

http://nothings.org/stb_image.c

2012/9/28 Anthony Catel <a.c...@weelya.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "skia-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/skia-discuss/-/CJEbuZ64xbAJ.
Reply all
Reply to author
Forward
0 new messages