469,283 Members | 2,263 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

How to realize a palette

I asked this in the VB NG and didn't get a response. I think this NG is no
apt to know this kind of thing so I'm trying here.

Trying to display the palette that is on the clipboard.

I get a palette from the clipboard and I want to make the picturebox display
it and realize it as its palette.

Actually the picturebox is on a usercontrol which is on the form containing
this code.

I get the palette OK and draw it but the colors are dithered so I assume my
attempt to realize it failed.

Any help would be appreciated

lHDataPalette = User.GetClipboardData(CF_PALETTE)

lNumDataPaletteEntries = GDI.GetPaletteEntries(lHDataPalette, 0, 256,
lDataLogPal.palPalEntry)

User.CloseClipboard()

If lNumDataPaletteEntries <> 0 Then

Dim lHDataPal As IntPtr

Dim lHPrevPal As IntPtr

Dim lHDCPic As IntPtr

lDataLogPal.palVersion = &H300S

lDataLogPal.palNumEntries = 256

lHDCPic = User.GetDC(ControlPicture1.PicHandle)

lHDataPal = GDI.CreatePalette(lDataLogPal)

lHPrevPal = GDI.SelectPalette(lHDCPic, lHDataPal, 0)

GDI.RealizePalette(lHDCPic)

lHDataPal = GDI.SelectPalette(lHDCPic, lHPrevPal, 0)

User.ReleaseDC(Handle, lHDCPic)

GDI.DeleteObject(lHDataPal)
Nov 16 '05 #1
4 3870
" Just Me" <gr****@a-znet.com> wrote in message
news:uk**************@TK2MSFTNGP15.phx.gbl...
I asked this in the VB NG and didn't get a response. I think this NG is no
apt to know this kind of thing so I'm trying here.

Trying to display the palette that is on the clipboard.


I am not sure what you are after.
I have a program available that displays all MS colours
and a program with which you can mix colours.
I would be happy to post them to you.
Nov 16 '05 #2
I'd like to see them as an educational tool.
But I want to display a palette from the clipboard.
I can get it and draw the colors but since the colors do not match the
screens palette they are dithered.
I'd like to make the picturebox use the palette I got from the clipboard.
I think the code I gave is close but doesn't seem to remove the dither -
like maybe the palette I tried to realize didn't take effect.
Thanks

"Adrian" <xx*@xxx.xx> wrote in message
news:ad***************************@freeler.nl...
" Just Me" <gr****@a-znet.com> wrote in message
news:uk**************@TK2MSFTNGP15.phx.gbl...
I asked this in the VB NG and didn't get a response. I think this NG is
no
apt to know this kind of thing so I'm trying here.

Trying to display the palette that is on the clipboard.


I am not sure what you are after.
I have a program available that displays all MS colours
and a program with which you can mix colours.
I would be happy to post them to you.

Nov 16 '05 #3
I don't know if this is possible. Before I investigate further would you
tell me why you need to do this? If you're running .NET I would have thought
that a machine that handles more than 256 colours is pretty much a
prerequisite?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

" Just Me" <gr****@a-znet.com> wrote in message
news:uk**************@TK2MSFTNGP15.phx.gbl...
I asked this in the VB NG and didn't get a response. I think this NG is no
apt to know this kind of thing so I'm trying here.

Trying to display the palette that is on the clipboard.

I get a palette from the clipboard and I want to make the picturebox
display it and realize it as its palette.

Actually the picturebox is on a usercontrol which is on the form
containing this code.

I get the palette OK and draw it but the colors are dithered so I assume
my attempt to realize it failed.

Any help would be appreciated

lHDataPalette = User.GetClipboardData(CF_PALETTE)

lNumDataPaletteEntries = GDI.GetPaletteEntries(lHDataPalette, 0, 256,
lDataLogPal.palPalEntry)

User.CloseClipboard()

If lNumDataPaletteEntries <> 0 Then

Dim lHDataPal As IntPtr

Dim lHPrevPal As IntPtr

Dim lHDCPic As IntPtr

lDataLogPal.palVersion = &H300S

lDataLogPal.palNumEntries = 256

lHDCPic = User.GetDC(ControlPicture1.PicHandle)

lHDataPal = GDI.CreatePalette(lDataLogPal)

lHPrevPal = GDI.SelectPalette(lHDCPic, lHDataPal, 0)

GDI.RealizePalette(lHDCPic)

lHDataPal = GDI.SelectPalette(lHDCPic, lHPrevPal, 0)

User.ReleaseDC(Handle, lHDCPic)

GDI.DeleteObject(lHDataPal)

Nov 16 '05 #4
In photshop you can develop for indexed 256 colors and coping to the
clipboard puts a palette there.
I want to display it.

BTW; While testing I put my display into 256 color mode and XP works find.

Maybe I just don't understand but I'd guess that if I realize a palette in
the picturebox HDC I should be able to display all those colors in the
picturebox without dithering.

Thanks for the interest
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I don't know if this is possible. Before I investigate further would you
tell me why you need to do this? If you're running .NET I would have
thought that a machine that handles more than 256 colours is pretty much a
prerequisite?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

" Just Me" <gr****@a-znet.com> wrote in message
news:uk**************@TK2MSFTNGP15.phx.gbl...
I asked this in the VB NG and didn't get a response. I think this NG is
MORE apt to know this kind of thing so I'm trying here.

Trying to display the palette that is on the clipboard.

I get a palette from the clipboard and I want to make the picturebox
display it and realize it as its palette.

Actually the picturebox is on a usercontrol which is on the form
containing this code.

I get the palette OK and draw it but the colors are dithered so I assume
my attempt to realize it failed.

Any help would be appreciated

lHDataPalette = User.GetClipboardData(CF_PALETTE)

lNumDataPaletteEntries = GDI.GetPaletteEntries(lHDataPalette, 0, 256,
lDataLogPal.palPalEntry)

User.CloseClipboard()

If lNumDataPaletteEntries <> 0 Then

Dim lHDataPal As IntPtr

Dim lHPrevPal As IntPtr

Dim lHDCPic As IntPtr

lDataLogPal.palVersion = &H300S

lDataLogPal.palNumEntries = 256

lHDCPic = User.GetDC(ControlPicture1.PicHandle)

lHDataPal = GDI.CreatePalette(lDataLogPal)

lHPrevPal = GDI.SelectPalette(lHDCPic, lHDataPal, 0)

GDI.RealizePalette(lHDCPic)

lHDataPal = GDI.SelectPalette(lHDCPic, lHPrevPal, 0)

User.ReleaseDC(Handle, lHDCPic)

GDI.DeleteObject(lHDataPal)


Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jean-Sebastien Carle | last post: by
reply views Thread by Carles | last post: by
15 posts views Thread by active | last post: by
3 posts views Thread by krishnasamy | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.