473,394 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 4077
" 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jean-Sebastien Carle | last post by:
I've been ripping my hair our trying to get this to work for a week and I can't seem to get it. I'm trying to display a 4BppIndexed Bitmap from within the ntoskrnl.exe file that contains no palette....
0
by: Micus | last post by:
Hi all, Does anyone have experience with using a palette with a progress control? Everything works fine with a scrollbar control, but I think there are issues with the progress control because it's...
0
by: Carles | last post by:
Hi, Currently, I use a cDIB class to manage all color depth DIBs. But now I would like to avoid selecting my hDIB into a DC, and process all through manipulating data directly from/through...
1
by: Stuart | last post by:
I am using the Python Imaging Library (PIL) to process GIF images. I need to be able to retrieve the RGB values for each color palette entry. I see that the 'Image' class has a 'palette'...
6
by: active | last post by:
I asked this in VB without results. I'm not surprised that no one there knows anything about because it's kind of an uncommon subject. Maybe some one here knows. Dim DataO As DataObject =...
15
by: active | last post by:
Below is a small but complete program that appears to show you can't retrive a Palette from the clipboard. This is true whether the palette is placed on the clipboard by Photoshop or Photoshop...
8
by: active | last post by:
Guess I'm looking for someone who likes to work difficult puzzles. I can't seem to ever retrieve a palette handle from the clipboard. Below is a simple test program that demonstrates the...
3
by: krishnasamy | last post by:
Hi, I have writing the code for change the Palette color of the Bitmap. But I didn't get any different between given image and result image. Here I given my code, Bitmap *bmp=new...
1
by: jj | last post by:
The following creates a copy of an image. It worked fine in Visual Studio 2005, but after installing Visual Studio 2008 then opening the solution as a ..net 2.0 project, I get an error on the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.