1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-06 03:30:23 +00:00
QB64-PE/internal/help/_PIXELSIZE.txt
2016-03-18 08:36:04 -03:00

49 lines
2 KiB
Plaintext

{{DISPLAYTITLE:_PIXELSIZE}}
The '''_PIXELSIZE''' function returns the color depth (Bits Per Pixel) of an image as 0 for text, 1 for 1 to 8 BPP or 4 for 32 bit.
{{PageSyntax}}
:: pixelsize% = '''_PIXELSIZE'''[({{Parameter|imageHandle&}})]
{{PageDescription}}
* If brackets and {{Parameter|imageHandle&}} are omitted, it is assumed to be the current write page.
* Returns:
:: 0 if the image or screen page specified by {{Parameter|imageHandle&}} is in text mode.
:: 1 If the image specified by {{Parameter|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.
* The [[SCREEN]] or [[_NEWIMAGE]] or [[_LOADIMAGE]] color(256 or 32) mode can influence the pixel sizes that can be returned.
* If {{Parameter|imageHandle&}} is an invalid handle, then an [[ERROR Codes|invalid handle]] error is returned.
''Snippet:'' Saving Images for later program use. Handle values could be saved to an array.
{{TextStart}} '' ''
handle1& = _Getimage(sx1, sy1, sx2, sy2, sourcehandle&) ' function call
{{Cb|FUNCTION}} GetImage& (sx1, sy1, sx2, sy2, sourcehandle&)
bytespp = {{Cb|_PIXELSIZE}}(sourcehandle&)
{{Cb|IF...THEN|IF}} bytespp = 4 {{Cb|THEN}} Pal = 32 {{Cb|ELSE}} {{Cb|IF...THEN|IF}} bytespp = 1 {{Cb|THEN}} Pal = 256 {{Cb|ELSE}} {{Cb|EXIT FUNCTION}}
h& = {{Cb|_NEWIMAGE}}({{Cb|ABS}}(sx2 - sx1) + 1, {{Cb|ABS}}(sy2 - sy1) + 1, Pal)
{{Cb|_PUTIMAGE}} (0, 0), sourcehandle&, h&, (sx1, sy1)-(sx2, sy2) 'image is not displayed
GetImage& = h&
{{Cb|END FUNCTION}} '' ''
{{TextEnd}}
{{small|Adapted from code by Galleon}}
''See examples:''
* [[SAVEIMAGE]] {{text|(SUB to convert image to bitmap)}}
* [[SaveIcon32]] {{text|(convert any image to icon)}}
* [[ThirtyTwoBit SUB]] {{text|(convert partial image to bitmap)}}
* [[Bitmaps]]
{{PageSeeAlso}}
* [[_LOADIMAGE]]
* [[_NEWIMAGE]]
* [[_PUTIMAGE]]
* [[_COPYPALETTE]]
{{PageNavigation}}