
TheCopy = DrawColorMatrix(TheOriginal, sa, R)Į.Graphics.DrawString((Alpha_VScrollBar.Value), f, br, Alpha_VScrollBar.Left, Alpha_VScrollBar.Bottom)Į.Graphics.DrawString((Red_VScrollBar.Value), f, br, Red_VScrollBar.Left, Red_VScrollBar.Bottom)Į.Graphics.DrawString("R", f, br, Red_VScrollBar.Left, Red_VScrollBar.Top - 14) G.DrawImage(bmpOrg, rect, 0, 0, bmpOrg.Width, bmpOrg.Height, GraphicsUnit.Pixel, image_attr)ĭim R As Single = Red_VScrollBar.Value / 255 Private Function DrawColorMatrix(bmpOrg As Bitmap, sa As Single, R As Single) As Bitmapĭim rect As Rectangle = New Rectangle(0, 0, bmpOrg.Width, bmpOrg.Height) What do you think? Is this how it should work? How does a good paint program do it normally (I mean the same basic changes not the details)?. So, based on Acamars sample, I made the red scrollbar range from -255 to 255 and the user can go negative and get back to the original (should they know what that was). Then I realized you cant set the original Then I added the R of RGB scrollbar thinking I would just redraw the image for the original so I could use all the variables ARGB. I got the alpha working with Pennies/Razerz method. Return RGB_Bitmap.Clone(Bmp.GetBounds(GraphicsUnit.Pixel), 32bppArgb) RGB_Bitmap = Bmp.Clone(Bmp.GetBounds(GraphicsUnit.Pixel), 24bppRgb) Private Function ResetAlphaChannel(Bmp As Bitmap) As Bitmap Me.BackgroundImage = ResetAlphaChannel(CType(Me.BackgroundImage, Bitmap)) G.DrawImage(bmp1, New Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, attributes) G.CopyFromScreen(New Point(0, 0), New Point(0, 0), New Size(500, 500), CopyPixelOperation.SourceCopy)ĭim cmxPic As Imaging.ColorMatrix = New Imaging.ColorMatrix()ĭim attributes As ImageAttributes = New ImageAttributesĪttributes.SetColorMatrix(cmxPic, ColorMatrixFlag.Default, ColorAdjustType.Bitmap) Using g As Graphics = Graphics.FromImage(bmp1) 'All this just creates an image with opacity 0.3 - For testing Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load To reset your alpha channel quicky, you can just clone your bitmap as I did in this example Private Sub VScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles Alpha_VScrollBar.Scroll

Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged TheOriginal = New Bitmap("c:\bitmaps\test1.jpg") Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint Using f As New Font("Arial", 10, FontStyle.Bold)Į.Graphics.DrawString((1 * Alpha_VScrollBar.Value), f, br, Alpha_VScrollBar.Left, Alpha_VScrollBar.Bottom)Į.Graphics.DrawString("Ap", f, br, Alpha_VScrollBar.Left, Alpha_VScrollBar.Top - 14) Private Sub Form5_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint G.DrawImage(TheOriginal, rect, 0, 0, TheOriginal.Width, TheOriginal.Height, GraphicsUnit.Pixel) G.DrawImage(TheOriginal, rect, 0, 0, TheOriginal.Width, TheOriginal.Height, GraphicsUnit.Pixel, image_attr) Using g As Graphics = Graphics.FromImage(bmp)ĭim rect As Rectangle = New Rectangle(0, 0, TheCopy.Width, TheCopy.Height)ĭim sa As Single = 1 - Alpha_VScrollBar.Value / 255ĭim cm As ColorMatrix = New ColorMatrix(New Single()() _ Using bmp As Bitmap = New Bitmap(TheCopy.Width, TheCopy.Height) PictureBox1.BackgroundImageLayout = ImageLayout.Zoom Private Sub Form2_Load(sender As Object, e As EventArgs) Handles Me.Load Private TheOriginal As Bitmap = New Bitmap("c:\bitmaps\rusty.jpg") In this example, I need to set the scrollbar up so I can restore the opacity when the bitmap is opened. Is there a way to get the current opacity or something from the file? So the problem is when I open the saved file with 50% opacity, I dont know its 50%. Restore the original I can set alpha to 2. Say the alpha value in the color matrix was 0.5 when saved. Now I want to save the changed image, open it again, and restore the original opacity to 100%.


I am using the color matrix alpha value to change a bitmaps opacity as shown.
