Results 1 to 5 of 5

Thread: Convert (Vb6 style) long rgb value to something useful in vb.net

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Convert (Vb6 style) long rgb value to something useful in vb.net

    Really, this should be simple...

    In VB6, you could represent colors using a long data type for the 64,000+ possible colors.....

    So if I have a data item (myMapLine(i).Colour) that holds a line's color using a long between 0 and 64,000, how the heck do I assign that in VB.net?

    VB Code:
    1. myPen = New Pen(Color.FromArgb(myMapLine(i).colour), myMapLine(i).thickness)

    That doesn't work... nothing appears at all....

  2. #2
    Hyperactive Member Bananafish's Avatar
    Join Date
    Jan 2001
    Posts
    394
    Try making the RGB value negative,

    ie

    VB Code:
    1. dim intColor as int32
    2.  
    3. intColor = myMapLine(i).Colour  * -1
    4. myPen = New Pen(Color.FromArgb(intColor), myMapLine(i).thickness)

  3. #3
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: Convert (Vb6 style) long rgb value to something useful in vb.net

    Originally posted by nemaroller
    VB Code:
    1. myPen = New Pen(Color.FromArgb(myMapLine(i).colour), myMapLine(i).thickness)

    That doesn't work... nothing appears at all....
    I struggled with this as well. The problem is the difference between RGB and ARGB, where a is the alpha blending part. Because this is 0 in RGB, the color is completely transparent, so in fact it is invisible.

    Try something like this:

    VB Code:
    1. myPen = New Pen(Color.FromArgb(myMapLine(i).colour OR &HFF000000), myMapLine(i).thickness)

  4. #4

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Thanks for the replies, at least something is drawing on the screen now, the first solution appears closer to the colors that resulted from the vb6 version, but they seem washed...

    The second solution changed the basic hue from red/orange to bluish....
    Last edited by nemaroller; Sep 17th, 2002 at 10:17 AM.

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    You could try if the ColorTranslator.FromOle yields better results.

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