Jump to content
Sign in to follow this  
pbsds

Saving images with alpha transparancy

Recommended Posts

pbsds

This is something I can't figure out, I have an array width the RGBA value of each pixel in a photo.

But when the image is saved it shows up non-transparent! But nothing else is corrupted...

this is the code im using:

Func PixelArrayToImage($Array,$Width,$Height,$out)
    _GDIPlus_StartUp()
    $Bitmap = _WinAPI_CreateBitmap($Width, $Height,1,32)
    $image = _GDIPlus_BitmapCreateFromHBITMAP($Bitmap)
    _WinAPI_DeleteObject($Bitmap)
    For $y = 0 to $Height-1 step 1
        For $x = 0 To $Width-1 step 1
            $temp = Hex($Array[$x+$y*$Width])
            DllCall($ghGDIPDll, "int", "GdipBitmapSetPixel", "hwnd", $image, "int", $x, "int", $y, "dword", Dec(StringRight($temp,2)&StringLeft($temp,6)))
        Next
    Next
    $Format = _GDIPlus_EncodersGetCLSID(StringUpper(FileType($out)))
    _GDIPlus_ImageSaveToFileEx($image, $out, $Format)
    _GDIPlus_ImageDispose($image)
    _GDIPlus_ShutDown()
EndFunc

Func FileType($file)
    $name = StringSplit($file, ".")
    return $name[UBound($name)-1]
EndFunc

Thanks. :D


Fuck 'em if they can't take a joke.

Share this post


Link to post
Share on other sites
pbsds

COMMON! I CAN't WAIT ANYMORE! >:(


Fuck 'em if they can't take a joke.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.