473,772 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetClipboa rdData(CF_PALET TE)

lNumDataPalette Entries = GDI.GetPaletteE ntries(lHDataPa lette, 0, 256,
lDataLogPal.pal PalEntry)

User.CloseClipb oard()

If lNumDataPalette Entries <> 0 Then

Dim lHDataPal As IntPtr

Dim lHPrevPal As IntPtr

Dim lHDCPic As IntPtr

lDataLogPal.pal Version = &H300S

lDataLogPal.pal NumEntries = 256

lHDCPic = User.GetDC(Cont rolPicture1.Pic Handle)

lHDataPal = GDI.CreatePalet te(lDataLogPal)

lHPrevPal = GDI.SelectPalet te(lHDCPic, lHDataPal, 0)

GDI.RealizePale tte(lHDCPic)

lHDataPal = GDI.SelectPalet te(lHDCPic, lHPrevPal, 0)

User.ReleaseDC( Handle, lHDCPic)

GDI.DeleteObjec t(lHDataPal)
Nov 16 '05 #1
4 4100
" Just Me" <gr****@a-znet.com> wrote in message
news:uk******** ******@TK2MSFTN GP15.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******** ******@TK2MSFTN GP15.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******** ******@TK2MSFTN GP15.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.GetClipboa rdData(CF_PALET TE)

lNumDataPalette Entries = GDI.GetPaletteE ntries(lHDataPa lette, 0, 256,
lDataLogPal.pal PalEntry)

User.CloseClipb oard()

If lNumDataPalette Entries <> 0 Then

Dim lHDataPal As IntPtr

Dim lHPrevPal As IntPtr

Dim lHDCPic As IntPtr

lDataLogPal.pal Version = &H300S

lDataLogPal.pal NumEntries = 256

lHDCPic = User.GetDC(Cont rolPicture1.Pic Handle)

lHDataPal = GDI.CreatePalet te(lDataLogPal)

lHPrevPal = GDI.SelectPalet te(lHDCPic, lHDataPal, 0)

GDI.RealizePale tte(lHDCPic)

lHDataPal = GDI.SelectPalet te(lHDCPic, lHPrevPal, 0)

User.ReleaseDC( Handle, lHDCPic)

GDI.DeleteObjec t(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@_spamkille r_bobpowell.net > wrote in message
news:%2******** *******@TK2MSFT NGP15.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******** ******@TK2MSFTN GP15.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.GetClipboa rdData(CF_PALET TE)

lNumDataPalette Entries = GDI.GetPaletteE ntries(lHDataPa lette, 0, 256,
lDataLogPal.pal PalEntry)

User.CloseClipb oard()

If lNumDataPalette Entries <> 0 Then

Dim lHDataPal As IntPtr

Dim lHPrevPal As IntPtr

Dim lHDCPic As IntPtr

lDataLogPal.pal Version = &H300S

lDataLogPal.pal NumEntries = 256

lHDCPic = User.GetDC(Cont rolPicture1.Pic Handle)

lHDataPal = GDI.CreatePalet te(lDataLogPal)

lHPrevPal = GDI.SelectPalet te(lHDCPic, lHDataPal, 0)

GDI.RealizePale tte(lHDCPic)

lHDataPal = GDI.SelectPalet te(lHDCPic, lHPrevPal, 0)

User.ReleaseDC( Handle, lHDCPic)

GDI.DeleteObjec t(lHDataPal)


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1850
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. This bitmap is the one everyone likes to change to customize their boot screen. My goal is not to edit the kernel, but simply to display the bitmap content in much the same way a resource editor does. My problem is that no matter what I do, the...
0
1086
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 a common control. For the scrollbar, I can select the palette in the WM_CTLCOLORSCROLLBAR message which works fine, but the progress bar does not send a similar message. The progress control displays and works fine, but the color of the bar and...
0
1164
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 lpBits (color data pointer). The problem comes at time to load palette based bitmaps through LoadImage API. Now, once I have hDIB, I select into a DC and extract palette using GetDIBColorTable. My question is if it's possible to extract palette without...
1
5822
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' attribute which returns an object of type 'ImagePalette'. However, the documentation is a bit lacking regarding how to maniuplate the ImagePalette class to retrieve the palette entries' RGB values. Can anyone point me to a short example? Thanks!
6
1304
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 = CType(Clipboard.GetDataObject(), DataObject) If DataO.GetDataPresent(DataFormats.Palette, False) Then Dim cp As ColorPalette = CType(DataO.GetData(DataFormats.Palette),
15
2056
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 or by the below program It lets you place a palette from a file or from a program on the clipboard and allows you to retrieve one from the clipboard. But you'll find the retrieved one is always "Nothing"
8
2505
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 problem. The program uses windows api to get a handle to a palette from the clipboard. The palette needs to be put there by another program - maybe Photoshop.
3
2397
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 Bitmap(L"skumar3.bmp"); INT size = bmp->GetPaletteSize();// bitmap->GetPaletteSize(); printf("The size of the palette is %d bytes.\n", size);
1
1482
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 'bmpOut.Palette = imageFile.Palette' line (see below). Anyone come across this or suggest a reason for the error? private static System.Drawing.Image CreateImageFile(System.Drawing.Image imageFile, int width, int height)
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.