English 中文(简体)
C++和GDI从副渔获物中分离出的多纬度 b草执行问题
原标题:Problem with Multigradient brush implementation from scatch in C++ and GDI

我正试图与全球移民与发展公司一道执行从C++的平时起的梯度。 我不想使用全球发展指数+或任何其他图表框架。 我想梯度方向(任意角)。

我在假体编码中的算法:

      For each pixel in x dirrection
      For each pixel in the y direction
          current position = current pixel - centre                      //translate origin 
          rotate this pixel according to the given angle
          scalingFactor =( rotated pixel + centre ) / extentDistance    //translate origin back 
          rgbColor = startColor + scalingFactor(endColor - startColor)

范围 距离是指从试金星中心穿过线的长度,梯度等于梯度的角。

Ok so far so good. I can draw this and it looks nice. BUT unfortunately because of the rotation bit the rectangle corners have the wrong color. The result is perfect only for angle which are multiples of 90 degrees. The problem appears to be that the scaling factor doesn t scale over the entire size of the rectangle.

我不敢肯定,如果你不视而不谈我的问题,那真是难以解释。

If anyone can help or redirect me to some helpful material I d be grateful.

最佳回答

Ok guys fixed it. Apparently the problem was that when I was rotating the gradient fill (not the rectangle) I wasn t calculating the scaling factor correctly. The distance over which the gradient is scaled changes according to the gradient direction. What must be done is to find where the edge points of the rect end up after the rotation and based on that you can find the distance over which the gradient should be scaled. So basically what needs to be corrected in my algorithm is the extentDistance.

How to do it:

•Transform the coordinates of all four corners

• 占全部四分之十的最小

• 占全部四×中的最大部分,称为最高点X

• ......

• 这两点之间的距离(最大和最小)是程度 差异

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

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 ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签