However the colors of my cursor are all wrong!
It looks like it is using a palette / a limited set of 16/32/256 colors?!
Is it possible to have 24bits/32bits colors cursor? (i.e. with millions of possible color value)
I found a way to do it! With the following API in sequences:
I want to convert graphics such as rectangles, circles, etc. to truetype files. However, I can't write the geometry data for graphics to these truetype files.Is there have any code or tutorial to achieve this goal？
I am programming in C++. I have a lot of work that uses the GDI, GDI+ or the older canvas to display graphs and chart. I need to draw a 3D mesh surface using these tools. Is there any sample code using these draw tools?
I have searched quite a bit with no luck. Unfortunately GDI is not considered a good option for 3D programming and almost all the samples are in OpenGL or Direct3D. I really can't use OpenGL or Direct3D without major changes to my code. GDI+ almost feels obsolete with very little activity on code web sites.
I went through my model creation process again; saved and exported after each step and checked the number of vertices in XNA.
Everything appears fine until the deform modifier is applied in Blender.
As a work-around I decided to export my model after applying modifier. Importing the model into a new blender file, and then exporting the model. This worked!
Before doing this, I had tried exporting my model in .x format but this didn't make any difference.
I'm not sure if this problem exists with any modifier or just the deform modifer.
I'm doing quite a bit of graphics work that involves displaying material on a cartesian coordinate graph using GDI+ methods (DrawLine, DrawRectangle, etc) in the Paint routines of a PictureBox.
I'm always having to deal with scaling, rotation matrices and the other complications because the picturebox needs to have it's 'world' scaled rotated and translated before displaying normal Cartesian coords properly. Even with all this, it's always extra work to handle the fact that pens and some other graphics objects then draw their sizes transformed as well, and mouse events don't necessarily return points correctly.
Many years ago, I used TrueBasic and it had a drawing component that you could set up as simple as giving the width, height and everything transformed accordingly. I'm looking for a dotnet component that will give me a similiar object so I can stop having to customize the existing picturebox. Paid components are fine, but I have to be able to use GDI+ to draw in it or it must support something similiar. I do *not* want to use graphing/charting components that require the graphics objects/points to be stored in their own arrays or other unique systems. I want to do the drawing myself.
please use System.Drawing namespace in your project.
where you find the Graphics class which will give you all option to Draw anything by using cartesian co-ordinate system.
public partial class WaveDisplay : UserControl
int _XDivision; //Total X Division
[DefaultValue(10.0f)]//1 Volt per Division
[DefaultValue(10.0f)]//1 Sec per Division
public int XDivisions
_XDivision = value;
public int YDivisions
_YDivision = value;
public float VoltagePerDivision
_voltsPerDivision = value;
public float TimePerDivision
_timePerDivision = value;
public override Image BackgroundImage
base.BackgroundImage = value;
public override ImageLayout BackgroundImageLayout
base.BackgroundImageLayout = value;
_voltsPerDivision = 10.0f;
_timePerDivision = 10.0f;
_XDivision = 10;
_YDivision = 10;
_s = new Sample();
protected override void OnPaint(PaintEventArgs e)
Graphics g = e.Graphics;
if (BackgroundImage != null)
Brush b = null;
b = new SolidBrush(this.BackColor);
Pen pen = new Pen(ForeColor);
Rectangle r = new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width, ClientRectangle.Height);
r.Inflate(new Size((int)(-ClientRectangle.Width * 0.1f),(int) (-ClientRectangle.Height * 0.1f)));
double xPixelPerDiv = (double)r.Width / (double)_XDivision;
double yPixelPerDiv = (double)r.Height /(double)_YDivision;
double TimePerUnit = _timePerDivision/_XDivision;
double VoltsPerUnit = _voltsPerDivision/_YDivision;
string s1 = null;
for (int i = 0; i <= _XDivision; i++)
g.DrawLine(pen, new Point((int)(r.Left + xPixelPerDiv * i), r.Top),
new Point((int)(r.Left + xPixelPerDiv * i), r.Bottom));
s1 = (_timePerDivision * i).ToString();
g.DrawString(s1, Font, new SolidBrush(ForeColor), new PointF((int)(r.Left + xPixelPerDiv * i), r.Bottom + 10));
for (int i = 0; i <= _YDivision; i++)
g.DrawLine(pen, new Point((int)(r.Left), (int)(r.Bottom - i * yPixelPerDiv)),
new Point((int)(r.Right), (int)(r.Bottom - i * yPixelPerDiv)));
s1 = (_voltsPerDivision * i).ToString();
g.DrawString(s1, Font, new SolidBrush(ForeColor), new PointF(r.Left - 15, (int)(r.Bottom - yPixelPerDiv * i)));
Thanks, I'm aware that the math can be done manually. I was hoping for a third-party component so I could focus my efforts elsewhere and not have to focus on writing code for the existing drawing components.
I learnt from an article I read that dx11 can't be used with vb in ease way. So, the available tutorials are limited to dx 5, 6, 7, 8 and 9. And my system has dx11 installed. So, I wanted to un-install dx11 and replace it with dx 8 or 9 but is not successful because dx 1r is higher than 8 and 9. How can I do the replacement?
The runtime is used by most games and may be already installed if you have installed some games on your system. The SDK is only required if you want to use DX for your own programs (it includes the runtime).
From the above runtime download link:
The DirectX runtime cannot be uninstalled
So you should try to use your version first. If you really need a development system with an older DX version, you must setup one using an old Windows version.
I am following a request to write C++ code for a label that contains several text elements in one single line, varying by font, size, color.... Ok, that can be done easily in GDI+ by measuring each element's width and then execute a DrawString for each of the text elements starting at its calculated position.
So far, I failed miserably.
The horizontal text positions did not appear to be correct. I reverted now to very simple text measuring tests which confused me even more.
Test 1: Use of MeasureString
With the same font, the width of the string "MM" does not match the double with of the string "M". This cannot be explained with eventual rounding problems.
Test2: Use of MeasureCharacterRanges
Used the same font as for the first test. The width of "MM" is now exactly double of the width of "M". But: The width of the "M" ist lightyears away from the measurement result in the first test.
I have added one more test which is using standard GDI, and I have changed the GDI+ font to units of pixels. Unfortunately, this third test shows results which do not match the previous results at all.
Does anybody have an idea why I get so different results?
Since I had not only added a third test but also changed the code of the first tests I am appending the full example here; the results I found have been added as comments:
void ApplWindow_TextDrawTest(HDC hDC)
Gdiplus::Graphics *G = new Gdiplus::Graphics(hDC);
Gdiplus::Font TextFont(L"Calibri", 36, Gdiplus::FontStyle::FontStyleBold, Gdiplus::Unit::UnitPixel);
constwchar_t *Text1M = L"M";
Gdiplus::PointF TextOrigin1M(0, 0);
constwchar_t *Text2M = L"MM";
Gdiplus::PointF TextOrigin2M(0, 50);
//--- Test #1: using MeasureString ----------
G->MeasureString(Text1M, (INT)wcslen(Text1M), &TextFont, TextOrigin1M, &MyFormat, &TextBounds1M);
G->MeasureString(Text2M, (INT)wcslen(Text2M), &TextFont, TextOrigin2M, &MyFormat, &TextBounds2M);
//--- Results: Text 1 Width= 44.414 ("M")//--- Text 2 Width= 76.828 ("MM")//--- Test #2: using MeasureCharacterRanges ----------
Gdiplus::RectF LayoutRect(0, 0, 1000, 100);
CRanges.First = 0; CRanges.Length = 1;
CRanges.First = 1; CRanges.Length = 1;
CRanges.First = 0; CRanges.Length = 2;
G->MeasureCharacterRanges(Text2M, (INT)wcslen(Text2M), &TextFont, LayoutRect, &MyFormat, 3, RegionsList);
RCode = RegionsList.GetBounds(&TextBounds1M, G); // Result: Text 1 Width = 32.000 ("M")
RCode = RegionsList.GetBounds(&TextBounds1M, G); // Result: Text 1 Width = 32.000 ("M"; the second char)
RCode = RegionsList.GetBounds(&TextBounds2M, G); // Result: Text 2 Width = 64.000 ("MM")//--- Test #3: using the good old GDI ----------int MapModeResult = SetMapMode(hDC, MM_TEXT); // MM_TEXT is equivalent to Unit::UnitPixel?
HFONT TextFont3 = CreateFont(36, 0, 0, 0, FW_BOLD, false, false, false, ANSI_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH | FF_DONTCARE, L"Calibri");
HGDIOBJ PrevFont = SelectObject(hDC, TextFont3);
BOOL RFlg = GetCharABCWidthsFloat(hDC, (UINT)'M', (UINT)'M', &ABCCharData); // Results: abcfA = 2.000; abcfB = 22.000; abcfC = 2.000//--- End of Test ---delete G;