Page 1 of 1

[img]Converting JPG to BMP fails with some JPG.[/img]

Posted: Fri May 02, 2003 1:19 pm
by CONVERT
I do not know if it's a bug or my mistake.

My program :

------------------------------------------------
UseJPEGImageDecoder()

GImage$ = "Dscn2727_recadre.jpg"

; GImage$ = "_affiche2721.jpg"

If LoadImage(0, GImage$) = 0
GLiberr$ = "Error reading " + GImage$
Else
imagebmp$ = "Wallpaperjc_tmp.bmp"
If SaveImage(0, imagebmp$, #PB_ImagePlugin_BMP) = 0
GLiberr$ = "Error writing from " + GImage$ + " to " + imagebmp$
Else
MessageRequester("","Good",0)
EndIf
EndIf

If GLiberr$ <> ""
MessageRequester("",GLiberr$,0)
EndIf

End
-------------------------------------------------
Generally, it works fine. But sometimes, a JPEG file makes the Saveimage fail. About 5 or 10 %.

These JPEG files are all made with a CoolPix 990, then worked with Ulead PhotoImpact 3.01, with "JPEG SmartSaver".

I select 2 cases : Dscn2727_recadre.jpg (saveimage fails) and _affiche2721.jpg (no problem).

You can find these pictures and the code at :
http://pg.ctjean.com/testpb/

Desactivate Debugger before F5. Sometimes, it halts.

Thanks if you find an explanation.
Jean.

Posted: Fri May 02, 2003 1:32 pm
by Max.
Did you try the library from http://www.purebasic.com/beta/?[/url]

Posted: Fri May 02, 2003 1:45 pm
by El_Choni
Looks like a problem with the BMP saver, rather than with the JPEG decoder. Maybe something to do with alignment or padding (the failing image is 1021x766).

Posted: Fri May 02, 2003 2:10 pm
by CONVERT
You are right.

It is a question of dimension.

I change from 1021 x 766 to 1024 x 768, and it works fine.

The same with 800 x 600.

Is it a bug of saveimage?

I ask this question to know if I try an other solution or if I wait for the correction.

Does the El Choni's beta library solve this problem?

Thanks a lot.
Jean.

Posted: Fri May 02, 2003 5:07 pm
by El_Choni
My lib only decodes (and is no longer beta). The link Max has posted will drive you to a beta PureBasic library (not mine) of the JPEG plugin, which works ok, but which doesn't solve this problem, because it seems to have to do with BMP saving, not JPEG decoding.

Posted: Fri May 02, 2003 5:31 pm
by Fred
I will take a look..

Posted: Fri May 02, 2003 8:02 pm
by geoff
I had trouble with SaveImage() to a BMP yesterday. I found that the bitmap header was saved but not the bitmap.

Unfortunately, when I tried to simplify the code to report a bug, the bug went away, so this may have been a bug in my program. I doubt this helps much. :?


Fred, do you know if the quality of loaded JPG images can be improved?
This has been asked elsewhere, but as things stand there seems no point developing software to load photographic quality images.

Posted: Fri May 02, 2003 10:21 pm
by Fred
I will take look on the JPEG decoder options..

Posted: Sat May 03, 2003 5:48 pm
by MeMyselfAndI
Fred wrote:I will take look on the JPEG decoder options..
Sounds good enough :wink:

Would be great if the user could change the output quality.