FINALLY IT'S HERE
PNG+Alpha in GM6.x
I think that this is GOOD place for some well.. an Introduction..
--> http://64digits.com/...etersvp/PNG.zip <--
This DLL is for GM6.x users like you that love PNGs. It loads and saves PNG files with alpha channels.
(the script headers are posted here)
//DON'T CALL THIS DIRECTLY!! it is used for other scripts to call it!!!
//loads a PNG file including alpha channel and returns the sprite
// example: sprite_index= png2sprite('file.png',[0,0])
// other example: global.mysprite = png2sprite('file.png', xorig,yorig);
// argument0: sprite to load
// DO NOT FORGET TO SPRITE_DELETE IT!!! (a=sprite_index; sprite_delete(a); sprite_index= something)
//saves a sprite as a 32bit PNG file
// argument0: sprite to save
// argument1: subimage
// argument2: where to save
//saves a surface as a 32bit PNG file with its alpha channel!
// argument0: surface to save
// argument1: where to save
// creates a 32-bit PNG file with alpha translucency from two BMP files
// alpha.bmp and RGB.bmp MUST exist. E.g. you first create the alpha.bmp
// and the RGB.BMP and then you must call this script
// do something...
// save it in a "RGB.BMP" (example: screen_save('rgb.bmp') or surface_save(...) or other saving function);
// do other thing.... grayscale only is recommended
// save it as "ALPHA.BMP"
// call this script: compose_png("File.png");
// argument0: file to create
// Loads a PNG file into two BMPs - alpha.bmp and RGB.BMP
// RGB.bmp is a RGB data, alpha.bmp is a grayscale alpha channel.
// You can then use these two files, for example, to load a sprite into the GM
// gm have a function - sprite_set_alpha_from_sprite - and it takes the alpha file into
// the account. decompose_png is useful if you want to export alpha channel for example, from a png
// or just the RGB data. Note that decompose_png do NOT actually converts PNG to BMP!
// example: decompose_png("file.png")
// Then you can use alpha.bmp and rgb.bmp as you want! NOTE that these two files are NOT kept forever!
// you must use them immediately after call to decompose_png
// argument0: file to decompose
Edited by petersvp, 19 September 2008 - 10:02 PM.