Page 1 of 1

SaveImage() and depths < 24 bits

Posted: Tue Mar 28, 2006 5:15 pm
by Rings
his error is still not solved.
PB4 can now create images in 8 bit,
the images is correctly converted,
but PB4 cannot save them in the format
given in CreateImage.

see this example code and the size of the saved' bitmap :)

Code: Select all

Procedure MakeDesktopScreenshot(ImageNr,x,y,Width,Height,depth) 
   hImage = CreateImage(ImageNr,Width,Height,depth) 
   hDC    = StartDrawing(ImageOutput(ImageNr)) 
   DeskDC = GetDC_(GetDesktopWindow_()) 
      BitBlt_(hDC,0,0,Width,Height,DeskDC,x,y,#SRCCOPY) 
   StopDrawing() 
   ReleaseDC_(GetDesktopWindow_(),DeskDC) 
   ProcedureReturn hImage 
EndProcedure

ScreenWidth = GetSystemMetrics_(#SM_CXSCREEN)
ScreenHeight = GetSystemMetrics_(#SM_CYSCREEN)
ColorDepth = GetDeviceCaps_(GetDC_(0),#BITSPIXEL)
Debug ColorDepth
;t1=GetTickCount_()
MakeDesktopScreenshot(0, 0, 0, ScreenWidth, ScreenHeight,8) 
;t2=GetTickCount_()
SaveImage(0, "C:\DesktopScreenshot.bmp");save always as screendepth
;t3=GetTickCount_()
;MessageRequester("Info",Str(t2-t1)+":"+Str(t3-t2),0)
and btw, try with 4 or 2 as depth :)

Posted: Tue Mar 28, 2006 5:21 pm
by Fred
Yes, it's more an issue than a bug, the format differents than 24 bits are not support for SaveSprite/SaveImage().

Posted: Wed Oct 03, 2007 6:01 am
by Joakim Christiansen
Would be very handy to support that. Is there any other methods we can use? I really need to be able to save jpegs as 8-16 bit pictures.

Posted: Wed Oct 03, 2007 9:07 am
by PB
> I really need to be able to save jpegs as 8-16 bit pictures

Is that even possible? I thought JPEGs were only 24bit for color, and 8bit for grey?

Posted: Wed Oct 03, 2007 10:21 am
by Kaeru Gaman
the format differents than 24 bits are not support for SaveSprite/SaveImage().
I think it's time to add this.
there are functions that need 8bit images, like AlphaSprite or Terrain.
at the moment it is not possible to create ressources for them with a PB-code.

Posted: Thu Oct 04, 2007 1:02 pm
by Joakim Christiansen
PB wrote:Is that even possible? I thought JPEGs were only 24bit for color, and 8bit for grey?
Not sure really, but 16bit would be handy. So I hope it does support at least that.
All I want is just less colors so my picture can take less space, and it would be handy for both jpg and png's.

Posted: Thu Oct 04, 2007 1:39 pm
by PB
> 16bit would be handy. So I hope it does support at least that.

I was right, it's only 24bits:

"The second fundamental advantage of JPEG is that it stores full color
information: 24 bits/pixel (16 million colors)."


Source: http://www.faqs.org/faqs/jpeg-faq/part1/

Posted: Fri Oct 05, 2007 12:49 pm
by Kaeru Gaman
ok, but I don't really care about JPG.

PNG is incredibly flexible, able to serve a lot of formats,
even 16bit grayscale or 64bit RGBA is a legal PNG-format.

it would really be nice and handy to properly solve all advantages of PNG,
including the compression-rate.

Posted: Fri Oct 05, 2007 1:37 pm
by PB
> I don't really care about JPG

I wasn't talking to you. :)

Posted: Fri Oct 05, 2007 2:35 pm
by Kaeru Gaman
hummm.. ok

he was talking about "jpegs as 8-16 bit" literally..

anyhow, BMP and PNG serve other bitdepths and thus should be supported.

Posted: Sat Oct 06, 2007 1:06 am
by Kaeru Gaman
Fred wrote:Yes, it's more an issue than a bug, the format differents than 24 bits are not support for SaveSprite/SaveImage().
I know I'm repeating myself, but I want to make it clear:

if you want to create HeightFields on your own, it is absolutely necessary
to be able to save 8bit resp. 16bit grayscale PNGs.

without this feature, you cannot use PB to wright your own Terrain-Creator-Tool.

I strongly recommend to add this feature latest along with newest OGRE in PB 4.30