Results 1 to 17 of 17

Thread: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-255

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-255

    I'm a little confused. I'm trying to write a file that writes the color in PictureBox1 to a new file like Yellow would read "255255000255", where the first 3 digits is red, 4-6 is green, 7-9 (where the 0s are) is blue and the final 3 is alpha,using SaveFileDialog1. My application keeps getting red zig zags in the code, but if it helps, here is what I have...

    Code:
    Imports System.ComponentModel
    
    Public Class Form1
        Function IntegerToColor(ByRef RGB As Int32) As System.Drawing.Color
            Dim Bytes As Byte() = BitConverter.GetBytes(RGB)
            Dim Alpha As Byte = Bytes(3)
            Dim Red As Byte = Bytes(0)
            Dim Green As Byte = Bytes(1)
            Dim Blue As Byte = Bytes(2)
            Return Color.FromArgb(Alpha, Red, Green, Blue)
        End Function
        Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            OpenFileDialog1.Filter = "J Pixel Color|*.pixcolu"
            If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
                Dim Text = IO.File.ReadAllText(OpenFileDialog1.FileName)
                If Text.Length = 12 Then
                    Dim rr As Byte
                    Dim gg As Byte
                    Dim bb As Byte
                    Dim aa As Byte
                    If Byte.TryParse(text.Substring(0, 3), rr) AndAlso rr >= 0 AndAlso rr <= 255 AndAlso
                       Byte.TryParse(text.Substring(3, 3), gg) AndAlso gg >= 0 AndAlso gg <= 255 AndAlso
                       Byte.TryParse(text.Substring(6, 3), bb) AndAlso bb >= 0 AndAlso bb <= 255 AndAlso
                       Byte.TryParse(text.Substring(9, 3), aa) AndAlso aa >= 0 AndAlso aa <= 255 Then
                        Dim clr = Color.FromArgb(aa, rr, gg, bb)
                        PictureBox1.BackColor = clr
                    Else
                        MessageBox.Show("Error. You Either Closed The Search, Selected An Invalid, Or Corrupt File, Or Selected A Folder.")
                    End If
                Else
                End If
    
            End If
        End Sub
    
        Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
            Dim result As DialogResult = MessageBox.Show("What is this box for, you ask? This is where the color will be displayed. You can view and edit the code in a text-editing app. I might make a save button in the near future.", "Help", MessageBoxButtons.OK)
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Console.Beep(500, 500)
            Dim result As DialogResult = MessageBox.Show("Are you sure you want to quit?", "Are you sure?", MessageBoxButtons.YesNo)
            If result = DialogResult.No Then
                Return
            ElseIf result = DialogResult.Yes Then
                End
            End If
        End Sub
    
        Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
            Using colu = New OpenFileDialog()
                With colu
                    .Filter = "My Pixel Color | *.pixcolu"
    
                    If (.ShowDialog = DialogResult.OK) Then
                        Dim result As DialogResult = MessageBox.Show("Would you like to close this color app when it opens in Notepad? Hitting YES will close this app and open the selected file in Notepad, hitting NO will keep the color app open and add a Notepad window with the selected file.", "How would you like to switch to Notepad?", MessageBoxButtons.YesNo)
                        If result = DialogResult.No Then
                            System.Diagnostics.Process.Start("notepad.exe", .FileName)
                        ElseIf result = DialogResult.Yes Then
                            System.Diagnostics.Process.Start("notepad.exe", .FileName)
                            End
                        End If
                    End If
                End With
            End Using
        End Sub
    
        Private Sub Form1_Close(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
    
        Private Sub Form1_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
            Console.Beep(500, 500)
            Dim result As DialogResult = MessageBox.Show("Are you sure you want to quit?", "Are you sure?", MessageBoxButtons.YesNo)
            If result = DialogResult.No Then
                e.Cancel = True
            ElseIf result = DialogResult.Yes Then
                Console.Beep(500, 100)
                Console.Beep(490, 100)
                Console.Beep(480, 100)
                Console.Beep(470, 100)
                Console.Beep(460, 100)
                Console.Beep(450, 100)
                Console.Beep(440, 100)
                Console.Beep(430, 100)
                Console.Beep(420, 100)
                Console.Beep(410, 100)
                Console.Beep(400, 100)
                Console.Beep(390, 100)
                Console.Beep(380, 100)
                Console.Beep(370, 100)
                Console.Beep(360, 100)
                Console.Beep(350, 100)
                Console.Beep(340, 100)
                Console.Beep(330, 100)
                Console.Beep(320, 100)
                Console.Beep(310, 100)
                Console.Beep(300, 100)
                End
            End If
        End Sub
    
        Private Sub NotifyIcon1_MouseDoubleClick(sender As Object, e As MouseEventArgs)
    
        End Sub
    
        Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
            Dim Colors As DialogResult
            Colors = ColorDialog1.ShowDialog()
            If Colors = Windows.Forms.DialogResult.OK Then
                PictureBox1.BackColor = ColorDialog1.Color
            End If
        End Sub
    
        Private Sub OpenFileDialog1_FileOk(sender As Object, e As CancelEventArgs) Handles OpenFileDialog1.FileOk
    
        End Sub
    
        Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
            Dim hexString As String = Nothing
            Dim hexString2 As String = Nothing
            Dim hexString3 As String = Nothing
            hexString = Hex(PictureBox1.BackColor.R)
            hexString2 = Hex(PictureBox1.BackColor.G)
            hexString3 = Hex(PictureBox1.BackColor.B)
            Clipboard.SetText("#" & hexString.ToString().PadLeft(2, "0") + hexString2.ToString().PadLeft(2, "0") + hexString3.ToString().PadLeft(2, "0"))
        End Sub
    
        Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
    
            Dim hexString As String = Nothing
            Dim hexString2 As String = Nothing
            Dim hexString3 As String = Nothing
            Dim hexString4 As String = Nothing
            hexString = Hex(PictureBox1.BackColor.R)
            hexString2 = Hex(PictureBox1.BackColor.G)
            hexString3 = Hex(PictureBox1.BackColor.B)
            hexString4 = Hex(PictureBox1.BackColor.A)
            hexString.ToString().PadLeft(3, "0"c)
            hexString2.ToString().PadLeft(3, "0"c)
            hexString3.ToString().PadLeft(3, "0"c)
            hexString4.ToString().PadLeft(3, "0"c)
            SaveFileDialog1.Filter = "My Pixel Color (*.pixcolu*)|*.pixcolu"
            If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK _
            Then
                SaveFileDialog1.Filter = "TXT Files (*.txt*)|*.txt"
                If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK _
           Then
                    My.Computer.FileSystem.WriteAllText _
                (SaveFileDialog1.FileName, WriteLine(hexString & hexString2 & hexString3 & hexString4).Text, True)
                End If
            End If
        End Sub
    
        Private Sub SaveFileDialog1_FileOk(sender As Object, e As CancelEventArgs) Handles SaveFileDialog1.FileOk
    
        End Sub
    End Class
    I'm sure the red zig-zags is telling me that there is an error, but I don't know what to do after searching. Could you please help? How do I write it so I can save with a text file in chosen location in digits 000 - 255, combined with the other digits ("RRRGGGBBBAAA")? (If you have heard from me before, I was asking and how to make it read files, but how to write it?) I'm sure you get the idea of what I am trying to do, at the end of the code.

    (Sorry if I have the code a little off.) Thank you for helping.

  2. #2
    Frenzied Member
    Join Date
    Nov 2017
    Posts
    1,981

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    If you post a bunch of code, always do something to indicate which line(s) of code are generating the errors. Also, you should use meaningful names for controls so that we don't have to guess that "Button6" is your "Save" button.

    That being said, one huge issue I see is highlighted below:

    My.Computer.FileSystem.WriteAllText _
    (SaveFileDialog1.FileName, WriteLine(hexString & hexString2 & hexString3 & hexString4).Text, True)
    The bolded piece is all kinds of wrong. It probably should just be something like:

    Code:
    My.Computer.FileSystem.WriteAllText _
                (SaveFileDialog1.FileName, (hexString & hexString2 & hexString3 & hexString4), True)
    That being said, the True at the end will append to the file, which I'm assuming you want, but I'm not sure, so I thought I would at least mention it in case that isn't what you want.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    That appeared to fix everything but one thing, now "My.Computer"
    Code:
    If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK _
            Then
                SaveFileDialog1.Filter = "My Pixel Color (*.pixcolu*)|*.pixcolu"
                If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                    My.Computer.FileSystem.WriteAllText _
                (SaveFileDialog1.FileName, (hexString & hexString2 & hexString3 & hexString4), True)
                End If
    is underlined as red, and is says, "'Computer' is not a member of '_4.My'." What happened here? Somethings not right; I tried that, and I tried taking out "Computer", "My.FileSystem.WriteAllText" and still has the red zig-zag.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    I tried this;
    Code:
            Dim hexString As String = Nothing
            Dim hexString2 As String = Nothing
            Dim hexString3 As String = Nothing
            Dim hexString4 As String = Nothing
            hexString = Hex(PictureBox1.BackColor.R)
            hexString2 = Hex(PictureBox1.BackColor.G)
            hexString3 = Hex(PictureBox1.BackColor.B)
            hexString4 = Hex(PictureBox1.BackColor.A)
            hexString.ToString().PadLeft(3, "0"c)
            hexString2.ToString().PadLeft(3, "0"c)
            hexString3.ToString().PadLeft(3, "0"c)
            hexString4.ToString().PadLeft(3, "0"c)
            SaveFileDialog1.Filter = "My Pixel Color (*.pixcolu*)|*.pixcolu"
            If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK _
            Then
                IO.File.WriteAllText _
            (SaveFileDialog1.FileName, (hexString & hexString2 & hexString3 & hexString4))
            End If
    unfortunately, instead of writing black as "000000000255", it wrote "000FF". I would like it to have 4 3-digit numbers, not 3 lowest-digit numbers and hex.

  5. #5
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,821

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Quote Originally Posted by Winston17 View Post
    That appeared to fix everything but one thing, now "My.Computer"
    Code:
    If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK _
            Then
                SaveFileDialog1.Filter = "My Pixel Color (*.pixcolu*)|*.pixcolu"
                If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                    My.Computer.FileSystem.WriteAllText _
                (SaveFileDialog1.FileName, (hexString & hexString2 & hexString3 & hexString4), True)
                End If
    is underlined as red, and is says, "'Computer' is not a member of '_4.My'." What happened here? Somethings not right; I tried that, and I tried taking out "Computer", "My.FileSystem.WriteAllText" and still has the red zig-zag.
    Where does _4 come from? Have you declared anything with the name My?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    I got part of it to work, I needed to have it convert each 4 channels (RGBA) to decimal and 3 digits.

    Tested saving, It wrote "000FF" instead of "000000000255".

    Making a few changes (Removing "Hex") did make it decimal, but instead of having the 3 digits in each 4 pixels, it only has lowest rounded digits (instead of "000000000255" I got "00025").

    Here is what I have...

    Code:
    Dim hexString As String = Nothing
            Dim hexString2 As String = Nothing
            Dim hexString3 As String = Nothing
            Dim hexString4 As String = Nothing
            hexString = (PictureBox1.BackColor.R)
            hexString2 = (PictureBox1.BackColor.G)
            hexString3 = (PictureBox1.BackColor.B)
            hexString4 = (PictureBox1.BackColor.A)
            hexString.ToString().PadLeft(3, "0"c)
            hexString2.ToString().PadLeft(3, "0"c)
            hexString3.ToString().PadLeft(3, "0"c)
            hexString4.ToString().PadLeft(3, "0"c)
            SaveFileDialog1.Filter = "My Pixel Color (*.pixcolu*)|*.pixcolu"
            If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK _
            Then
                IO.File.WriteAllText _
            (SaveFileDialog1.FileName, (hexString & hexString2 & hexString3 & hexString4))
            End If
    I want 0 to be saved and written as text reading 000 on each 4 pixels, and 1 as 001, 5 as 005, 10 as 010, 25 as 025, 100 as 100 and so... up to 255 as 255.

    I want to add leading 0s before the number if possible to make triple digits. Do I need to do "If less than 10" or "If less than 100" and add 0s if needed?

  7. #7
    Frenzied Member
    Join Date
    Nov 2017
    Posts
    1,981

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Have you heard of the phrase "All dressed up with no place to go"?

    The lines of code where you are adding leading 0's are the getting "all dressed up" piece, but you aren't assigning the resulting value to anything, the "no place to go" piece.

    It should be something like:

    Code:
    hexString = hexString.PadLeft(3, "0"c)
    Last edited by OptionBase1; May 8th, 2022 at 10:01 AM.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    I ran into a new problem. It works, but while working, I noticed the ColorPicker doesn't support transparency/alpha.
    So, I tried to make 3 buttons to adjust it (buttons renamed for comprehension):
    Code:
        Private Sub InvisibleButton_Click(sender As Object, e As EventArgs) Handles InvisibleButton.Click
            Dim hexString4 As String = Nothing
            hexString4 = (PictureBox1.BackColor.A)
            hexString4 = 0
        End Sub
    
        Private Sub SolidButton_Click(sender As Object, e As EventArgs) Handles SolidButton.Click
            Dim hexString4 As String = Nothing
            hexString4 = (PictureBox1.BackColor.A)
            hexString4 = 255
        End Sub
    
        Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
            Dim hexString4 As String = Nothing
            hexString4 = (PictureBox1.BackColor.A)
            hexString4 = 128
        End Sub
    But when I hit the buttons, nothing happens, I even tried checking the file created in my app, it is stuck on "255".
    How do I do one of the following?:

    Plan A. Make 3 buttons and have it set alpha on Invisible (0), Transparent (128) and Solid (255)

    Plan B. Make a number box ranging 0 - 255, link it to "PictureBox1.BackColor.A" and adjust alpha/transparency that way

    Plan C. Set ColorDialog to allow Alpha (But it can't...This one pretty much failed)

    Plan D. Download a different or modified version of ColorPicker, and import that to my app and use it to adjust transparency

    Plan E. Get help on other ways to do it

    Plan F. Ask the manufacturers of Visual Studio 2019, Microsoft to add the feature (Lets try to avoid this one)

    Plan F. Remove Alpha from program (This one I also want to avoid)

    Can anyone, please, help?

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,823

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    The problem there is that you have declared hexString4 inside each of the routines - and variables declared inside a routine only exist inside that routine (the ones inside other routines are different variables, even if they have the same name).

    To share a variable between routines you could pass it as a parameter (which isn't apt here) or you can declare the variable outside any routines (such as at the top of the class, just after the Public Class line) which should work for you in this case.

    Note that if you do declare a variable outside of a routine, you should avoid declaring any variables inside routines with the same name (it causes confusion while writing/reading the code).

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Sorry, I wrote F twice in my last message, it was supposed to say;

    Plan A. Make 3 buttons and have it set alpha on Invisible (0), Transparent (128) and Solid (255)

    Plan B. Make a number box ranging 0 - 255, link it to "PictureBox1.BackColor.A" and adjust alpha/transparency that way

    Plan C. Set ColorDialog to allow Alpha (But it can't...This one pretty much failed)

    Plan D. Download a different or modified version of ColorPicker, and import that to my app and use it to adjust transparency

    Plan E. Get help on other ways to do it

    Plan F. Ask the manufacturers of Visual Studio 2019, Microsoft to add the feature (Lets try to avoid this one)

    Plan G. Remove Alpha from program (This one I also want to avoid)



    With the "routines declared" thing, Could you give me a few good-and-bad examples of code, si_the_geek?

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,823

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Your code in post #8 would be changed to this:
    Code:
        Dim hexString4 As String = Nothing
    
        Private Sub InvisibleButton_Click(sender As Object, e As EventArgs) Handles InvisibleButton.Click
            hexString4 = 0
        End Sub
    
        Private Sub SolidButton_Click(sender As Object, e As EventArgs) Handles SolidButton.Click
            hexString4 = 255
        End Sub
    
        Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
            hexString4 = 128
        End Sub
    To use the value in your save routine, just remove the declaration (dim) of hexString4, and remove the line hexString4 = (PictureBox1.BackColor.A)

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Like this?
    Code:
    Private Sub SolidButton_Click(sender As Object, e As EventArgs) Handles SolidButton.Click
            hexString4 As String = Nothing
            hexString4 = 255
        End Sub
    It didn't work...

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Quote Originally Posted by si_the_geek View Post
    Your code in post #8 would be changed to this:
    Code:
        Dim hexString4 As String = Nothing
    
        Private Sub InvisibleButton_Click(sender As Object, e As EventArgs) Handles InvisibleButton.Click
            hexString4 = 0
        End Sub
    
        Private Sub SolidButton_Click(sender As Object, e As EventArgs) Handles SolidButton.Click
            hexString4 = 255
        End Sub
    
        Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
            hexString4 = 128
        End Sub
    To use the value in your save routine, just remove the declaration (dim) of hexString4, and remove the line hexString4 = (PictureBox1.BackColor.A)
    But you didn't delete Dim here if you mean this (In thick letters)?
    Code:
        Dim hexString4 As String = Nothing
    
        Private Sub InvisibleButton_Click(sender As Object, e As EventArgs) Handles InvisibleButton.Click
            hexString4 = 0
        End Sub
    
        Private Sub SolidButton_Click(sender As Object, e As EventArgs) Handles SolidButton.Click
            hexString4 = 255
        End Sub
    
        Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
            hexString4 = 128
        End Sub

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Dec 2021
    Posts
    69

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    OK! Got the Alpha to work.
    But now...
    What do I use in the "question-marks" to color itself it's own color, or preserve color, but change alpha to the number?
    Could not find a "Color.FromAlpha" tool to change just the transparency, So using "Color.FromArgb", and I have to change the Red-Green-Blue to themselves so they don't change...How?

    Code:
        Private Sub InvisibleButton_Click(sender As Object, e As EventArgs) Handles InvisibleButton.Click
            PictureBox1.BackColor = Color.FromArgb(0, ?, ?, ?)
        End Sub
    
        Private Sub SolidButton_Click(sender As Object, e As EventArgs) Handles SolidButton.Click
            PictureBox1.BackColor = Color.FromArgb(255, ?, ?, ?)
        End Sub
    
        Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
            PictureBox1.BackColor = Color.FromArgb(128, ?, ?, ?)
        End Sub
    I only need to change the alpha, not the colors. I got colors already, I just need to keep them memorized or the same. Can anyone tell me what I need?

  15. #15
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,821

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Quote Originally Posted by Winston17 View Post
    OK! Got the Alpha to work.
    But now...
    What do I use in the "question-marks" to color itself it's own color, or preserve color, but change alpha to the number?
    Could not find a "Color.FromAlpha" tool to change just the transparency, So using "Color.FromArgb", and I have to change the Red-Green-Blue to themselves so they don't change...How?

    Code:
        Private Sub InvisibleButton_Click(sender As Object, e As EventArgs) Handles InvisibleButton.Click
            PictureBox1.BackColor = Color.FromArgb(0, ?, ?, ?)
        End Sub
    
        Private Sub SolidButton_Click(sender As Object, e As EventArgs) Handles SolidButton.Click
            PictureBox1.BackColor = Color.FromArgb(255, ?, ?, ?)
        End Sub
    
        Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
            PictureBox1.BackColor = Color.FromArgb(128, ?, ?, ?)
        End Sub
    I only need to change the alpha, not the colors. I got colors already, I just need to keep them memorized or the same. Can anyone tell me what I need?
    Presumably you would need to copy the existing values for R, G, and B

  16. #16
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,823

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Quote Originally Posted by Winston17 View Post
    Quote Originally Posted by si_the_geek View Post
    To use the value in your save routine, just remove the declaration (dim) of hexString4, and remove the line hexString4 = (PictureBox1.BackColor.A)
    But you didn't delete Dim here if you mean this (In thick letters)?
    That line of my post was referring to your save routine... meaning that you should use just the Dim I showed (which creates a variable all routines in the file can share), and remove the Dim that is inside the save routine (which creates a completely different variable which happens to have the same name).

  17. #17
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,636

    Re: How do I make a color written to file as "RRRGGGBBBAAA", each pixel showing 000-2

    Quote Originally Posted by Winston17 View Post
    What do I use in the "question-marks" to color itself it's own color, or preserve color, but change alpha to the number?
    You could do this:-
    Code:
            Dim alpha As Byte = 150 'Alpha value
    
            Me.PictureBox1.BackColor = Color.FromArgb((Me.PictureBox1.BackColor.ToArgb And &HFFFFFF) Or (CInt(alpha) << 24))
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width