SaveImage() and depths < 24 bits

Just starting out? Need help? Post your questions and find answers here.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

SaveImage() and depths < 24 bits

Post 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 :)
SPAMINATOR NR.1
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Yes, it's more an issue than a bug, the format differents than 24 bits are not support for SaveSprite/SaveImage().
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post 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.
I like logic, hence I dislike humans but love computers.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post 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.
I like logic, hence I dislike humans but love computers.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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/
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I don't really care about JPG

I wasn't talking to you. :)
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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
oh... and have a nice day.
Post Reply