graphics/manip.bi

Summary
graphics/manip.bi
LicenseCopyright © 2007-2014, FreeBASIC Extended Library Development Group
ext.gfx
Macros
FBEXT_FBGFX_PIXELPTRClear way to gain a pointer to a FBGFX image’s pixels of any type.
Functions
grayscaleConverts a color image into grayscale.
flipVerticalFlips an image on it vertical axis.
flipHorizontalFlips an image on it horizontal axis.
changeColorAttempts to change one color to another in a Image buffer.
RotateRotates a image buffer.
RotoZoomRotates and scales an image buffer.
RotoZoomASMRotates and scales an image buffer.
BlurBlurs an image buffer.
Scale2Xperforms the Scale2X algorithm on an image.
AlphaBlitperforms additive alpha blending on an image.
Intensifyperforms brighten/darken filtering on an image.

License

Copyright © 2007-2014, FreeBASIC Extended Library Development Group

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com/p/fb-extended-lib/wiki/License

ext.gfx

Summary
Macros
FBEXT_FBGFX_PIXELPTRClear way to gain a pointer to a FBGFX image’s pixels of any type.
Functions
grayscaleConverts a color image into grayscale.
flipVerticalFlips an image on it vertical axis.
flipHorizontalFlips an image on it horizontal axis.
changeColorAttempts to change one color to another in a Image buffer.
RotateRotates a image buffer.
RotoZoomRotates and scales an image buffer.
RotoZoomASMRotates and scales an image buffer.
BlurBlurs an image buffer.
Scale2Xperforms the Scale2X algorithm on an image.
AlphaBlitperforms additive alpha blending on an image.
Intensifyperforms brighten/darken filtering on an image.

Macros

FBEXT_FBGFX_PIXELPTR

#define FBEXT_FBGFX_PIXELPTR(t,
v) cast( t ptr, (v) + 1 )

Clear way to gain a pointer to a FBGFX image’s pixels of any type.

Parameters

tthe type (without the ptr) to cast to.
vthe variable referring to the FB.IMAGE (must be a FB.IMAGE ptr)

Returns

Pointer of the type passed pointing to the raw pixels of a FB.IMAGE.

See Also

Image

Functions

grayscale

declare function grayscale (
   byval img as Image ptr,  
   byval skip_trans as ext.bool =  ext.bool.true
) as Image ptr

Converts a color image into grayscale.

Parameters

imgImage buffer containing the image to convert
skip_transBoolean, should we skip the transparent pixels? defaults to true

Returns

A new image containing the grayscale version, destroy with imagedestroy when done.

flipVertical

declare function flipVertical (byval img As const Image Ptr) As Image ptr

Flips an image on it vertical axis.

Parameters

imgImage buffer to work on.

Returns

A pointer to the vertically flipped Image.

flipHorizontal

declare function flipHorizontal (byval img As const Image Ptr) As Image ptr

Flips an image on it horizontal axis.

Parameters

imgImage buffer to work on.

Returns

A pointer to the horizontally flipped Image.

changeColor

declare sub changeColor (byref img as Image ptr,  
byval from_ as uinteger,  
byval to_ as uinteger,  
byval include_alpha as ext.bool =  ext.bool.false,
byval is_font as ext.bool =  ext.bool.false)

Attempts to change one color to another in a Image buffer.

Parameters

imgImage buffer to work on.
from_uinteger representation of the color to change.
to_uinteger representation of the color to change to.
include_alphaoptional flag to determine if the alpha channel is included in the color check, defaults to false.
is_fontoptional flag to determine if the buffer is a FBGFX font buffer, defaults to false.

Rotate

declare sub Rotate(byref dst as Image ptr =  0,
byref src as const Image ptr,  
byref positx as integer,  
byref posity as integer,  
byref angle as integer  )

Rotates a image buffer.

Parameters

dstthe image buffer to write to.
srcthe image buffer to rotate.
positxx position (center of image) to draw the rotated image onto the destination buffer
posityy position (center of image) to draw the rotated image onto the destination buffer
anglethe angle in degrees to rotate the image.

RotoZoom

declare sub RotoZoom(byref dst as Image ptr =  0,
byref src as const Image ptr,  
byref positx as integer,  
byref posity as integer,  
byref angle as integer,  
byref zoomx as single,  
byref zoomy as single  )

Rotates and scales an image buffer.  (per axis)

Parameters

dstthe image buffer to write to.
srcthe image buffer to rotate/zoom.
positxthe x position to “put” on the dst image buffer.
positxthe y position to “put” on the dst image buffer.
anglethe angle in degrees to rotate the image.
zoomxthe amount to zoom on the x axis.
zoomythe amount to zoom on the y axis.

RotoZoomASM

declare sub RotoZoomASM(byref dst as Image ptr =  0,
byref src as const Image ptr,  
byval positx as integer,  
byval posity as integer,  
byref angle as integer,  
byref zoomx as single,  
byref zoomy as single =  0,
byval transcol as uinteger =  &hffff00ff)

Rotates and scales an image buffer.  (per axis): 32 bit images only. could possibly add other depths if requested.

Parameters

dstthe image buffer to write to.
srcthe image buffer to rotate/zoom.
positxthe x position to “put” on the dst image buffer.
positxthe y position to “put” on the dst image buffer.
anglethe angle in degrees to rotate the image.
zoomxthe amount to zoom on the x axis.
zoomythe amount to zoom on the y axis.  (optional parameter: if omitted, zoomx value is used.)
transcolthe transparent color.  (optional parameter: if omitted, fbgfx’s *magic pink*(&hffff00ff) color is used.)

Blur

declare sub Blur(byref dst as Image ptr,
byref src as const Image ptr,
byref blur_level as integer)

Blurs an image buffer.

Parameters

dstthe image buffer to write to.
srcthe image buffer to blur.
blur_levelthe amount of blur to apply.

Notes

When attempting to apply a blur level of <= 0 this function simply copies the source image into the destination image.

Scale2X

declare sub Scale2X(byref dst as Image ptr =  0,
byref src as const Image ptr,  
byref positx as integer,  
byref posity as integer  )

performs the Scale2X algorithm on an image.

Parameters

dstthe image buffer to write to.  Use 0 to draw to the screen.
srcthe image buffer to to perform the algorithm on.
positxthe x position to place the scaled sprite.
positythe y position to place the scaled sprite.

AlphaBlit

declare sub AlphaBlit(byval dst as Image ptr,
byval src as const Image ptr,
byref positx as integer,
byref posity as integer,
byref malpha as integer)

performs additive alpha blending on an image.

Parameters

dstthe image buffer to write to.  Use 0 to draw to the screen.
srcthe image buffer to to perform the algorithm on.
positxthe x position to place the scaled sprite.
positythe y position to place the scaled sprite.
malphathe additive alpha value to add.

Intensify

declare sub Intensify(byval dst as IMAGE ptr,
byval src as const IMAGE ptr,
byref positx as integer,
byref posity as integer,
byref intensity as integer)

performs brighten/darken filtering on an image.

Parameters

dstthe image buffer to write to.  Use 0 to draw to the screen.
srcthe image buffer to to perform the algorithm on.
positxthe x position to place the scaled sprite.
positythe y position to place the scaled sprite.
intensitythe amount to darken/brighten the image.
#define FBEXT_FBGFX_PIXELPTR(t,
v) cast( t ptr, (v) + 1 )
Clear way to gain a pointer to a FBGFX image’s pixels of any type.
declare function grayscale (
   byval img as Image ptr,  
   byval skip_trans as ext.bool =  ext.bool.true
) as Image ptr
Converts a color image into grayscale.
declare function flipVertical (byval img As const Image Ptr) As Image ptr
Flips an image on it vertical axis.
declare function flipHorizontal (byval img As const Image Ptr) As Image ptr
Flips an image on it horizontal axis.
declare sub changeColor (byref img as Image ptr,  
byval from_ as uinteger,  
byval to_ as uinteger,  
byval include_alpha as ext.bool =  ext.bool.false,
byval is_font as ext.bool =  ext.bool.false)
Attempts to change one color to another in a Image buffer.
Provides a New-able FB.IMAGE replacement with built-in memory management and convenience functions while maintaining compatibility with current fbgfx functions including ImageInfo.
declare sub Rotate(byref dst as Image ptr =  0,
byref src as const Image ptr,  
byref positx as integer,  
byref posity as integer,  
byref angle as integer  )
Rotates a image buffer.
declare sub RotoZoom(byref dst as Image ptr =  0,
byref src as const Image ptr,  
byref positx as integer,  
byref posity as integer,  
byref angle as integer,  
byref zoomx as single,  
byref zoomy as single  )
Rotates and scales an image buffer.
declare sub RotoZoomASM(byref dst as Image ptr =  0,
byref src as const Image ptr,  
byval positx as integer,  
byval posity as integer,  
byref angle as integer,  
byref zoomx as single,  
byref zoomy as single =  0,
byval transcol as uinteger =  &hffff00ff)
Rotates and scales an image buffer.
declare sub Blur(byref dst as Image ptr,
byref src as const Image ptr,
byref blur_level as integer)
Blurs an image buffer.
declare sub Scale2X(byref dst as Image ptr =  0,
byref src as const Image ptr,  
byref positx as integer,  
byref posity as integer  )
performs the Scale2X algorithm on an image.
declare sub AlphaBlit(byval dst as Image ptr,
byval src as const Image ptr,
byref positx as integer,
byref posity as integer,
byref malpha as integer)
performs additive alpha blending on an image.
declare sub Intensify(byval dst as IMAGE ptr,
byval src as const IMAGE ptr,
byref positx as integer,
byref posity as integer,
byref intensity as integer)
performs brighten/darken filtering on an image.