I am working on understanding collision detection and have decided to create a program that simulates Pacman. Simply put when a Pacman runs into a Ghost it dies.
I specify how many Pacmen I would like and in my MainForm_Paint (called when my control needs painting) I create an array of the specified amount of a class I created called P...
Normally when I override the OnPaint method, I create pens and brushes, etc inside it and then dispose them.
I also read somewhere that instead of recreating these pens and brushes, etc to create them once as static members, and then dispose them once when the form is closed, etc.
Is this a better practice?
Is there a better way for t...
I have a color A that I'd like to transform into color C, by using color B. So I'd like to know the blending formula F in GDI+, where F = F(A, B) = C. A is the "bottom color" and B is an overlay color above A, which together with A yields C.
Cheers,
// Magnus
...
I've perused the MSDN documentation and I couldn't find a statement one way or the other. What I'm interested in is:
Can I call GdiplusStartup() on one thread and then use Gdiplus on another thread? Or do I need to call GdiplusStartup() for each thread?
If I have a Bitmap object on thread 1 and different one on thread 2, can they bot...
I'm drawing lots of images (all of them dimensions=24x24 pixelformat=32BppPArgb) onto a Control using a Drawing.Graphics object and the DrawImage() function. It's possible to zoom out in my application which means that the Graphics object has a Transform Matrix attached to it which controls both zooming and panning.
There's no point in ...
Hey guys!
Got a quick question about Windows EMF/EMF+ files. Reading the documentation, I realize that an EMF/EMF+ file is just a bunch of GDI/GDI+ commands. So what's the supported way for reading in an EMF/EMF+ file and then displaying it in either MFC or WinForms?
Thanks,
Alex
...
I've implemented a plotter using wxGraphicsContext. The development was done using wxGTK, and the graphics was very fast.
Then I switched to Windows (XP) using wxWidgets 2.9.0. And the same code is extremely slow. It takes about 350 ms to render a frame. Since the user is able to drag the plotter with the mouse to navigate it feels very...
below is my code which throws exception because i am using the 'using' statement with the memory stream, i.e. it gets disposed at the end and when i try to save the image it throws the exception.
using(MemoryStream memoryStream = new MemoryStream())
{
ImageCodecInfo imageEncoder = GetEncoderInfo("image/jpeg");
EncoderParameter...
I get different result using Graphics.DrawString when rendering a chart for ASP.NET website. Text looks fine on development environment but bold and ugly on production.
Chart sample on production is here.
I can not post the link on chart sample from development environment, but I uploaded it on AmiProject website with name GanttChartOnD...
Hi,
I've got a Windows Form that circulates through images which are displayed on the form as a slideshow. The way I'm doing this is to have a Panel control the size of the form it resides in, and add an event handler that draws an Image object that exists in memory.
void panel_Paint(object sender, PaintEventArgs e)
{
if (_bShowImage...
Hi,
I've got a global Graphics object created from a Panel. At regular intervals an image is picked up from the disk and drawn into the panel using Graphics.DrawImage(). It works fine for a few iterations and then I'm getting the following helpful exception:
System.Runtime.InteropServices.ExternalException: A generic error occurred in ...
I am drawing an image from MetaFile (emf) and then apply some rotation transformations to it all within the OnPaint of a UserControl. After applying those transformation how can I calculate the normal untransformed rectangular bounding box of this in screen coordinates? I need this to be able to resize the rotated image to the size of th...
i get an
A generic error occurred in GDI+
exception when I call img.Save(path, jpegCodec, encoderParams);
here is all of the code :
private Image img;
private void button1_Click(object sender, EventArgs e)
{
this.img = Image.FromFile(@"path");
pictureBox1.Image = img;
if (img.Height < pictur...
Is there a way to draw an emf metafile (exported form a drawing tool) with antialiasing enabled? The tools I tried are not capable of exporting emf files antaliased so I wondered if I can turn it back on manually when drawing the emf in the OnPaint override of my Controls.
If anyone can confirm that is technically possible to generate ...
Using .NET's System.Drawing.Graphics GDI stuff, I have a shape consting of two arrays of points. They are the red and green pixels in the image below.
Now I am trying to fill the interior of this shape with a color. Drawing it as simple lines works just fine. Like this:
g.DrawCurve(Pens.Red, points1);
g.DrawCurve(Pens.Green, p...
I have the following PathPoints and PathTypes arrays (format: X, Y, Type):
-177.477900, 11021.670000, 1
-614.447200, 11091.820000, 3
-1039.798000, 10842.280000, 3
-1191.761000, 10426.620000, 3
-1591.569000, 10493.590000, 3
-1969.963000, 10223.770000, 3
-2036.929000, 9823.960000, 3
-2055.820000, 9711.180000, 3
-2048.098000, 9595.5460...
Before Windows 7 (and the new image codecs: WIC) I used the following (very fast but dirty) method to create a Gif encoded image with white as the transparent color:
MemoryStream target = new memoryStream(4096);
image.Save(target, imageFormat.Gif);
byte[] data = target.ToArray();
// Set transparency
// Check Graphic Control Extension s...
I'd like to use Direct2D for my .Net application using the Windows Code pack. Since some of my users are using XP, I need to provide a GDI+ fallback. I wonder how people usually do this kind of fallback.
Do they abstract/interface all the necessary graphics feature into some custom generic library? If so, is there any open-source librar...
Given an array of points, it is easy to draw a line based on these, e.g. using the GraphicsPath class.
For instance, the following array of points...
[0]: (0,0)
[1]: (100,0)
[2]: (0,100)
[3]: (100,100)
...describes a line that resembles a Z.
But here comes the challenge; I need to draw rounded corners with a radius of e.g. 10 pixels...
I am coding in GDI+ C++,
I want to serialize StringFormat into file.
How can I do this ?
Many thanks!
...