Hello all,
I'm trying to find the equavalent of DWORD, WORD, CIEXYZTRIPLE in C#. I see that the BITMAPV5HEADER structure uses these as Types. Does anyone know?
Thanx
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
christian de wetPosted Aug 29, 2007, 4:57 AM
Thanks for thr reply and the effort! Greatly appreciated. I tried out Format32bppPArgb and I still get a bluish background. I tried Lockbits and get a black background. However, I took a look at the AlphaBlend method and that seems to work quite well. However, I do need to set the background color of the overlaying Bitmap to black so that the underlying colors are not distorted. Maby I just need to do some fine tuning. I'm just a bit worried about the performance implications of AlphaBlend as compared to BitBlt.
Thanks for the help on this!
Kind regards,
Nathanael
AlanPosted Aug 28, 2007, 7:02 PM
I thought I'd have a look at the code for Bitmap.GetHBitmap() using Reflector for a clue as to what might be happening here but all I could see was that it was calling the unmanaged GDI+ function GdipCreateHBITMAPFromBitmap().
However, having googled on that, it led me to this rather bad-tempered thread:
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic21736.aspx
Depending on who you believe, there's either a bug in GdipCreateHBITMAPFromBitmap() which causes this behaviour or you need to convert the bitmap to Format32bppPARGB before calling BitMap.GetHBitmap() to get rid of the bluish tint. The latter suggestion is worth a try.
christian de wetPosted Aug 28, 2007, 9:28 AM
Thanks for the reply. I got it. I'm just still struggling with the HBitmap having a blue background when setting the original bitmap's background to transparent and converting it to an HBitmap. I have a post on this but no one has replied yet. I would appreciate if someone can help me with this pls. It's quite urgent.
Thanx for the help.
AlanPosted Aug 28, 2007, 9:04 AM
The equivalent of DWORD (4 byte unsigned integer) is uint.
The equivalent of WORD (2 byte unsigned integer) is ushort.
As for CIEXYZTRIPLE, here's a literal translation for P/Invoke purposes which requires 2 C# structs:
[StructLayout(LayoutKind.Sequential]
public struct CIEXYZTRIPLE
{
public CIEXYZ ciexyzRed;
public CIEXYZ ciexyzGreen;
public CIEXYZ ciexyzBlue;
}
[StructLayout(LayoutKind.Sequential]
public struct CIEXYZ
{
public int ciexyzX;
public int ciexyzY;
public int ciexyzZ;
}
According to the MSDN docs:
"The CIEXYZTRIPLE structure contains the x, y, and z coordinates of the three colors that correspond to the red, green, and blue endpoints for a specified logical color space."
I don't know whether this means anything to you (it meant nothing to me) but I'm a bit clearer after reading this excellent article which discusses various color systems including Cie XYZ and how to convert between them:
http://www.codeproject.com/cs/algorithms/colorspace1.asp?print=true#xyz2