English 中文(简体)
Colors in SDL acting very weird
原标题:

I m making a program in SDL.NET, where I need to draw a filled polygon. I figured it might be good to reuse the polygon surface instead of remaking it every time i need to draw, so I make the surface like this, and then save it to a dictionary afterwards:

polySur = Video.Screen.CreateCompatibleSurface(70, 70, true);
polySur.TransparentColor = Color.Magenta;
polySur.Fill(Color.Magenta);
polySur.Transparent = true;
poly.Draw(polySur, Color.LightGreen, false, true);

poly is the Polygon object I ve created beforehand.

You might think that this will draw a light green polygon when the surface is blitted to the screen; it doesn t. The resulting polygon is cyan! I discovered through experimentation that if I make a Color with Color.FromArgb, the R channel becomes red, G channel becomes cyan, and B channel becomes black.

However, if I set the second boolean in the Draw call to false (disabling the filling), i get a light green outline. Obviously, the fill operation is causing the colors to mess up.

Any ideas?

问题回答

It s a bug: http://sourceforge.net/tracker/index.php?func=detail&aid=3127181&group_id=52340&atid=466516

Line 196 of Polygon uses the color RGG to fill instead of RGB. This make sit impossible to get a blue color, and tends to tint any color other than red.

Frustrating, yes. Especially when your game hinges on being able to draw polygons.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签