Page 1 of 1

Outputting 32 bit JPG image.

Posted: Sun Jun 02, 2024 7:09 pm
by matalog
This program outputs an image, that windows reports to have a bit depth of 24.

Should it not output a 32 bit image?

Code: Select all

#width=1000
#height=1000
OpenWindow(0,100,0,#width,#height,"Window")
CreateImage(0,#width,#height,32)
Debug ImageDepth(0)
ImageGadget(0,0,0,#width,#height,ImageID(0))

StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
UseJPEGImageEncoder()
Box(100,100,800,800,RGBA(255,255,255,120))
StopDrawing()
SetGadgetState(0,ImageID(0))
Delay(40)

   If Not SaveImage(0,"bitdepthtest.jpg", #PB_ImagePlugin_JPEG,99,32)
        MessageRequester("Error","File has not been saved correctly",#PB_MessageRequester_Ok)
EndIf
Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow 

Re: Outputting 32 bit JPG image.

Posted: Sun Jun 02, 2024 7:17 pm
by wombats
I might be wrong, but I don't think JPEG supports 32-bit.

Re: Outputting 32 bit JPG image.

Posted: Sun Jun 02, 2024 7:55 pm
by infratec
In PB a 32 bit image means an image with transparence. 3 x 8 bit colors + 1 x 8 bit transparency.

JPG does not support transparency.
Only PNG, GIF, TIFF, WebP, QOI and PNM can handle transparency.
Also SVG, but that's not a pixel format.

This results in PNG for PB or QOI/PNM if you use my implementation:
QOI:
https://www.purebasic.fr/english/viewto ... 90#p578590
PNM:
https://www.purebasic.fr/english/viewto ... 61#p615861

IrfanView can handle QOI

Re: Outputting 32 bit JPG image.

Posted: Sun Jun 02, 2024 10:04 pm
by BarryG
infratec wrote: Sun Jun 02, 2024 7:55 pmOnly PNG, GIF, TIFF, WebP, QOI and PNM can handle transparency.
And BMP.

Re: Outputting 32 bit JPG image.

Posted: Tue Jun 04, 2024 7:47 pm
by matalog
Thanks guys.