transfer alpha

highboy

New member
Joined
Sep 25, 2008
Messages
2
Programming Experience
Beginner
hi there hope all is well.im trying to transfer the alpha channel from one image to another and am having trouble.if anyone could steer me the right way i would be very thankful.i have this to show where im at with my code.

VB.NET:
Dim bm As New Bitmap(PictureBox1.Image)
        Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)
        Dim bm1 As New Bitmap(PictureBox2.Image)
        Dim gr As Graphics = Graphics.FromImage(PictureBox2.Image)
        Dim x As Integer
        Dim y As Integer
        Dim PixelSize As Integer = 4
        Dim bmd As BitmapData = bm.LockBits(New Rectangle(0, 0, 300, 80), System.Drawing.Imaging.ImageLockMode.ReadOnly, bm.PixelFormat)
        Dim bmd1 As BitmapData = bm1.LockBits(New Rectangle(0, 0, 300, 80), System.Drawing.Imaging.ImageLockMode.WriteOnly, bm1.PixelFormat)
        For y = 0 To bmd1.Height - 1
            For x = 0 To bmd.Width - 1
                Marshal.ReadByte(bmd.Scan0, (bmd.Stride * y) + (4 * x + 3))
                Marshal.WriteByte(bmd1.Scan0, (bmd1.Stride * y) + (4 * x + 3), 255)
            Next
        Next
        
        bm.UnlockBits(bmd)
        bm1.UnlockBits(bmd1)
        PictureBox3.Image = bm1
        PictureBox3.Image.Save("c:/1.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
 
Last edited by a moderator:
basically nothing that's why i don't understand it lol.i got the code from Using the LockBits method to access image data but he shows an example to change all the blue bytes to full strength 255.so following what he was saying that the following three bytes contain the green, red and alpha bytes i figured i could lock the bytes read the alpha then write it to the other image.that's all im after for i have a sting of text that centers on picturebox1 and the i fill the picturebox2 with a color from colordialog and want to combine both.thanks for the reply and if you want i can upload the solution code i have so far.
 
Back
Top