Outputting 32 bit JPG image.

Just starting out? Need help? Post your questions and find answers here.
User avatar
matalog
Enthusiast
Enthusiast
Posts: 305
Joined: Tue Sep 05, 2017 10:07 am

Outputting 32 bit JPG image.

Post 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 
wombats
Enthusiast
Enthusiast
Posts: 720
Joined: Thu Dec 29, 2011 5:03 pm

Re: Outputting 32 bit JPG image.

Post by wombats »

I might be wrong, but I don't think JPEG supports 32-bit.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Outputting 32 bit JPG image.

Post 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
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: Outputting 32 bit JPG image.

Post by BarryG »

infratec wrote: Sun Jun 02, 2024 7:55 pmOnly PNG, GIF, TIFF, WebP, QOI and PNM can handle transparency.
And BMP.
User avatar
matalog
Enthusiast
Enthusiast
Posts: 305
Joined: Tue Sep 05, 2017 10:07 am

Re: Outputting 32 bit JPG image.

Post by matalog »

Thanks guys.
Post Reply