1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-20 22:05:15 +00:00
qb64/internal/help/_PIXELSIZE.txt
Luke Ceddia b586eafd3b Integrated _BLINEINPUT into regular LINE INPUT for BINARY files
LINE INPUT will now use the faster method if passed a file handle
that has been opened FOR BINARY. As such, the _BLINEINPUT command
has been removed.

qb64.bas now takes advantage of this for reading from '$include files,
at least in Include Manager 1. Some tweaking of internal/source/main.txt
was required to get things into a sane state, so I'm holing off changing
the compiler any further so the auto-builder can make sure everything's
smoothed over.

Note: Everything should still compile as normal; I'm just being overcautious.
2014-07-27 00:06:17 +10:00

47 lines
1.9 KiB
Plaintext

The {{KW|_PIXELSIZE}} function returns the color depth (Bits Per Pixel) of an image.
{{PageSyntax}}
:''return&'' = {{KW|_PIXELSIZE}}([{{Parameter|imageHandle&}}])
{{PageDescription}}
* If {{Parameter|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 {{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.
''Example:'' Saving Images for later program use. Handle values could be saved to an array.
{{CodeStart}} '' ''
handle1& = _Getimage(sx1, sy1, sx2, sy2, sourcehandle&) ' function call
{{Cl|FUNCTION}} GetImage& (sx1, sy1, sx2, sy2, sourcehandle&)
bytespp = {{Cl|_PIXELSIZE}}(sourcehandle&)
{{Cl|IF}} bytespp = 4 {{Cl|THEN}} Pal = 32 {{Cl|ELSE}} {{Cl|IF}} bytespp = 1 {{Cl|THEN}} Pal = 256 {{Cl|ELSE}} {{Cl|EXIT FUNCTION}}
h& = {{Cl|_NEWIMAGE}}({{Cl|ABS}}(sx2 - sx1) + 1, {{Cl|ABS}}(sy2 - sy1) + 1, Pal)
{{Cl|_PUTIMAGE}} (0, 0), sourcehandle&, h&, (sx1, sy1)-(sx2, sy2) 'image is not displayed
GetImage& = h&
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
{{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}}