gdi+

c++ display more than one image gid+

im trying to display image when left mouse button is down. i can display the image but if the left mouse button is down again than the older image would be deleted. here is my code display image function { Graphics graphics(hdc); POINT pt; GetCursorPos( ScreenToClient(hWnd, Image shot(L"RegularShots.png"); grap...

get weird cursor position

Ok so I'm working with vectors today yaya! well im also working with getcursorpos() and i get weird results. here is the code: VOID fRegularShot(HDC hdc, HWND hWnd) { Graphics graphics(hdc); Image shot(L"RegularShots.png"); long index=0; while(index<=(long)pRegularShots.size()) { index+=2; int x=pRegu...

Transfer or copy created graphic values on mouseUp event to Paint event

How can I put my created graphic codes on the paint event? I'm having troubles displaying It to the paint. I tried to add Points to a List but the lines I have drawn are merging. Help! Here's the code: private Point _ps = new Point(); private Point _pe = new Point(); private TransparentPanel _thispan; private Rectangle _SelectRect; pri...

Should I create new Pens/Brushes per Paint request or keep them throughout the application lifecycle?

I have an application that does a lot of drawing, let's pretend it's a Viso-like application. It has objects that have multiple sub-objects that are drawn, things can be connected, resized etc. Currently when I call paint on a particular sub-object or object, I do the following: using(var pen = new Pen(this.ForeColor)) { // Paint fo...

Save createGraphics in a file as image

Hi, How can I transfer the values of my graphics to a bitmap so I can save it as jpg or bmp file. here's my code: private void pictureBox1_Paint_1(object sender, PaintEventArgs e) { using(var p = new Pen(Color.Blue, 4)){ for (int i = 0; i < _listPS.Count; i++) { e.Graphics.DrawLine(_pen, _l...

Font size discrepancy in .NET GDI+?

I am wracking my brains in trying to understand the discrepancy between the font sizes users select or specify (for example, using a FontDialog) and the em-size reported by the Font class in .NET. For example: using (FontDialog dlg = new FontDialog()) { if (dlg.ShowDialog() == DialogResult.OK) { Console.WriteLine("Selected ...

doing pInvoke and can't get the right hDC

So I'm trying to get the right Device Context so I can set the gamma ramp on individual monitors in an N monitor configuration (2+). I've tried [DllImport("gdi32.dll")] static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string lpszOutput, IntPtr lpInitData); With this method I'm using the string "DISPLAY" for lpszDr...

c++ repaint part of window

i know how to repaint the full window but i don't know how to repaint a pieace of window like i draw a squre using gdi+ than i want to change it's coordinates so i want to repaint the squre not the whole window anyidea? i also tried this RECT rect2; rect2.left=0; rect2.top=100; rect2.right=225; rect2.bottom=300; InvadiateRect(hwnd, &...

Click two new points and draw a line between those two points using mouse event

Hi, Any suggestions how to create a line by clicking two new points then draw a line between them? I am trying to create a distance tool like the one in adobe acrobat. Image Example ...

Rotate Text by 90 degrees with GDI+

I want to draw text to a GDI Surface and rotate this text by 90 degrees counter clockwise. I would prefer to use DrawText to draw the text because it supports carriage return. I tried to use a font with lfEscapement (see the code below) but the line is not rotated - one line gets rendered over the other. Is there any possibility to rotat...

c++ gdi image array

im trying to make an array of images Image something(L"something.png"); instead of that Image something[2]; something[0]=(L"something.png"); any idea ...

Where does WPF's FontFamily.Source retrieve its value from?

I have two applications that use the same data to create a UI, one is using WPF and the other is using GDI. I'm using a font called Myriad Condensed Web, according to the font name attribute in Windows. I have no problem instantiating the System.Drawing.FontFamily object using the given font name. However, when I create this font using W...

Calculate the bounding box of a GDI+ drawing for bitmap export

I have a .NET Windows.Forms diagram editor that can export its diagrams as bitmaps. It also comes with a command line utility that just converts diagrams to bitmap images. I don't want to scale the diagram to a given bitmap size; instead, I want to size the bitmap based on the diagram's bounding box. I can easily determine it after dra...

PrinterSetting are ignored while printing an Image

I'm trying to print an Image using PrintDocumentin C# but somehow the setting (like Number of Pages and Image Quality ) are ignored while printing and preview. Is there anything wrong in following code, Am I missing something? private void button1_Click(object sender, EventArgs e) { using (var printDialog = new PrintDialog()) ...

c# GDI+ rendering problem

Hi, Not sure if anyone else has seen this, but I am rendering a custom control that has zoom functionality. Lets say for simplicity sake that I am just drawing one rectangle with border width = 1 in the viewable area of the control. When I alter the zoom (graphics.ScaleTransform()) the rectangle's borders take on different sizes (someti...

GDI+ LockBits / Alpha

I am attempting to create clipping mask out of a PNG with an alpha channel by copying the alpha values from my PNG over another same sized image. All using LockBits and then UnlockBits. It appears that my channel is correctly being set but I don't see it being used in subsequent drawing operations. In an attempt to simplify things as mu...

Why is my c# paint method running out of memory?

I'm new to c#, and trying to learn by writing some simple apps to get familiar with the syntax and .NET library. The most recent miniproject I took on is a polar clock like the one found here. One of the problems I noticed early on was that the app would constantly "flicker", which really took away from the presentation, so I read onli...

C# Graphics object

Hello, Question: How to check if Graphics object is usable. My Problem: I create Graphics object from form and give it to "object X" for drawing, when form closes and "object X" tries to draw into Graphics object, GDI+ error occurs 0x80004005. So i need to check if Graphics is drawable only having that Graphics object. Any ideas? ...

Why should I do manual double buffering? (C#)

I am working on a game in C# (either 2.0 or 3.5 havn't decided yet). The game will be played on a map with a hexagonal grid. I appreciate that the UI for this map should use double buffering (lots of layers, so slow drawing). I know that I can enable double buffering through a style, or create my own buffer and handle it myself. Most...

Transparency problem. drawing in winforms

So i have this control, and im overriding it to create a transparent background with this: protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x20; return cp; } } On the paint method, im doing this: protect...