Jump to content

Saving images with alpha transparancy


pbsds
 Share

Recommended Posts

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...