rigz.max2dext: Functions Modinfo Source  

Extended Max2D

Max2D module provides a few extra features for the standard max2d, mainly the loading of images in PreMultipliedAlpha mode which enables and additional blend mode - screen blend, plus making it a lot easier to grab a screen with the lpaha channel intact.

In order to use this properly for your own use (this is mainly for use internally by timelinefx you need to follow a few rules:

  1. Use SetGraphicsDriverEXT and set the driver to the specific max2d driver you're using, ie., GLMax2DDriverEXT(),D3D7Max2DDriverEXT() or D3D9Max2DDriverEXT()
  2. After setting that make sure you call InitEXTGraphics() to initialise the extended driver.
  3. For all images you load with LoadImageEXT or LoadAnimImageEXT with the PreMultiAlpha falg set to true, you need to use the following max2d state change commands instead of the normal ones: SetBlendEXT, SetColorEXT and SetAlphaEXT.
  4. If you want to switch between SetBlend for a normal image (non-premultiplied alpha) and SetBlendEXT then you need to use ResetBlendMode after calling SetBlendEXT and ResetBlendModeEXT after using the normal SetBlend. This is only necessary when you switch bettwen the two, so if you used SetBlendEXT 10 times in a row you' only have to use ResetBlendMode after the 10th one befoer using the normal SetBlend command.

Functions Summary

GetBlendEXT get the current Blend Mode of SetBlendEXT.
GrabPixmapEXT Grab pixmap.
InitEXTGraphics Initialise the Extended Graphics Driver.
LoadAnimImageEXT Load a multi-frame image.
LoadImageEXT Load an image.
SetAlphaEXT Set current alpha level.
SetBlendEXT Set current blend mode.
SetClsColorEXT Reset the state_blend of the normal SetBlend command.
SetColorEXT Set current color.

Functions

Function GetBlendEXT:Int()
Returnsthe current blendmode.
Descriptionget the current Blend Mode of SetBlendEXT.

Function GrabPixmapEXT:TPixmap(x:Int, y:Int, width:Int, height:Int)
DescriptionGrab pixmap.

Function InitEXTGraphics()
DescriptionInitialise the Extended Graphics Driver.
InformationIt's important that you run this before attemtping to use any of the EXT commands.

Function LoadAnimImageEXT:TImage(url:Object, cell_width:Int, cell_height:Int, first_cell:Int, cell_count:Int, flags:Int = -1, PreMultiAlpha:Int = False)
ReturnsAn image object.
DescriptionLoad a multi-frame image.
InformationThis will load an animation image and pre multiply all it's colour with the alpha channel PreMultiAlpha is set to true.

Function LoadImageEXT:TImage(url:Object, flags:Int = -1, ChangeImage:TPixmap(pixmap:TPixmap))
ReturnsA new image object.
DescriptionLoad an image.
InformationThis will load an image and pre multiply all it's colour with the alpha channel if PreMultiAlpha is set to True.

Function SetAlphaEXT(alpha:Float)
DescriptionSet current alpha level.
InformationUse this when working with images that have premultiplied alpha alpha should be in the range 0 to 1.

alpha controls the transparancy level when the ALPHABLEND blend mode is in effect. The range from 0.0 to 1.0 allows a range of transparancy from completely transparent to completely solid.


Function SetBlendEXT(blend:Int)
DescriptionSet current blend mode.
InformationSetBlend controls how pixels are combined with existing pixels in the back buffer when drawing commands are used in BlitzMax.

blend should be one of:

Blend modeEffect
MASKBLENDPixels are drawn only if their alpha component is greater than .5
SOLIDBLENDPixels overwrite existing backbuffer pixels
ALPHABLENDPixels are alpha blended with existing backbuffer pixels
LIGHTBLENDPixel colors are added to backbuffer pixel colors, giving a 'lighting' effect
SCREENBLENDBlends the colours similar to the photoshop screen blend
SHADEBLENDPixel colors are multiplied with backbuffer pixel colors, giving a 'shading' effect


Function SetClsColorEXT(red:Int, green:Int, blue:Int, alpha:Float = 1)
DescriptionReset the state_blend of the normal SetBlend command.
InformationAfter using SetBlendEXT, Max2d won't know whether it's blendmode is the same anymore, so use this to reset it and ensure it works properly next time you use it. end rem Function ResetBlendMode() SetBlend 10 SetBlend GetBlend() End Function

rem bbdoc: Reset the state_blend of the SetBlendEXT command about: After using SetBlend, Max2dEXT won't know whether it's blendmode is the same anymore, so use this to reset it and ensure it works properly next time you use it. end rem Function ResetBlendModeEXT() SetBlendEXT 10 SetBlend GetBlendEXT() End Function

Rem bbdoc: Set current Cls color plus the alpha level about: The red, green and blue parameters should be in the range of 0 to 255. Alpha should be in the range 0 to 1.

The default cls color is black.


Function SetColorEXT(red:Int, green:Int, blue:Int)
DescriptionSet current color.
InformationUse this when working with images that have premultiplied alpha

The red, green and blue parameters should be in the range of 0 to 255.


Module Information

Version1
AuthorPeter Rigby
LicenseMIT
CopyrightRigzSoft