PIXELSIZE - QB64 Wiki

PIXELSIZE

From QB64 Wiki

Jump to: navigation, search

The _PIXELSIZE function returns the color depth (Bits Per Pixel) of an image.


Syntax:

return& = _PIXELSIZE([imageHandle&])


Description:

  • If imageHandle& is omitted, it is assumed to be a handle to the current write page.
  • Returns:
0 if the image or screen page specified by imageHandle& is in text mode.
1 If the image specified by imageHandle& is in 1(B & W), 4(16 color) or 8(256 color) BPP mode.
4 Image specified is a 24/32-bit compatible mode. Pixels use three bytes, one per Red, Green and Blue color intensity.


Snippet: Saving Images for later program use. Handle values could be saved to an array.

handle1& = _Getimage(sx1, sy1, sx2, sy2, sourcehandle&) ' function call FUNCTION GetImage& (sx1, sy1, sx2, sy2, sourcehandle&) bytespp = _PIXELSIZE(sourcehandle&) IF bytespp = 4 THEN Pal = 32 ELSE IF bytespp = 1 THEN Pal = 256 ELSE EXIT FUNCTION h& = _NEWIMAGE(ABS(sx2 - sx1) + 1, ABS(sy2 - sy1) + 1, Pal) _PUTIMAGE (0, 0), sourcehandle&, h&, (sx1, sy1)-(sx2, sy2) 'image is not displayed GetImage& = h& END FUNCTION

Adapted from code by Galleon


See examples:


See also:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page