mixing gdi and gdi+

mixing gdi and gdi+

Post by Davi » Sat, 07 Jun 2003 17:19:34



Hi, I am writing a component.

I do something like the Paint method below.

The problem is that the two Canvas.Ellipse calls dosn't draw on the same
place on the canvas, so GDI plus must change the coordinate system somehow.
How can I fix this?

regards,
David

procedure TMyControl.Paint;
var
  g: TGPGraphics;
  p: TGPPen;
begin
  g := TGPGraphics.Create(Canvas.Handle);
  p := TGPPen.Create(MakeColor(127, 255, 0, 255));
  try
    Canvas.Ellipse(Bounds(10, 10, 20, 20));

    g.DrawEllipse(10, 10, 20, 20);

    Canvas.Ellipse(Bounds(10, 10, 20, 20));
  finally
    g.Free;
  end;
end;

--
mvh,
David

 
 
 

mixing gdi and gdi+

Post by Jonas Nystr? » Sun, 08 Jun 2003 00:56:36


Hmm... There seems to be something fundamentally different between the way
the two libraries calculates...

Example:
Canvas.Rectangle(Bounds(10, 10, 1, 1));  // draws nothing
g.DrawRectangle(10, 10, 20, 20);             // draws a 2 x 2 pixel
rectangle

Maybe you have to decrease the GDI+ w and h values by 1 in your routines to
make them correspond... Not much of an answer, is it? :-)

Just for curiosity: What's the point mixing?

Regards / Jonas



Quote:> Hi, I am writing a component.

> I do something like the Paint method below.

> The problem is that the two Canvas.Ellipse calls dosn't draw on the same
> place on the canvas, so GDI plus must change the coordinate system
somehow.
> How can I fix this?

> regards,
> David

> procedure TMyControl.Paint;
> var
>   g: TGPGraphics;
>   p: TGPPen;
> begin
>   g := TGPGraphics.Create(Canvas.Handle);
>   p := TGPPen.Create(MakeColor(127, 255, 0, 255));
>   try
>     Canvas.Ellipse(Bounds(10, 10, 20, 20));

>     g.DrawEllipse(10, 10, 20, 20);

>     Canvas.Ellipse(Bounds(10, 10, 20, 20));
>   finally
>     g.Free;
>   end;
> end;

> --
> mvh,
> David


 
 
 

mixing gdi and gdi+

Post by Jonas Nystr? » Sun, 08 Jun 2003 15:34:00


Sorry for error in code example above. It should be

Quote:> Canvas.Rectangle(Bounds(10, 10, 1, 1));  // draws nothing
> g.DrawRectangle(10, 10, 1, 1);             // draws a 2 x 2 pixel

 Regards / Jonas
 
 
 

mixing gdi and gdi+

Post by Davi » Wed, 11 Jun 2003 19:01:53


Quote:> Maybe you have to decrease the GDI+ w and h values by 1 in your
> routines to make them correspond... Not much of an answer, is it? :-)

Thanks but nope thats not it!

I found the problem, but not the solution.

My control inherites from TGraphicControl, ie it dosn't have its own canvas.
and GDIPlus resets the canvas origin. So everything works as expected when I
interit from TCustomControl instead.  But I don't want to use
TCustomControl, any ideas?

Quote:> Just for curiosity: What's the point mixing?

I am drawing map handling/rendering code wich is based on TCanvas, now I
want to add pransparent polygon objects to the map. So the plan is to use
GDI+ for these objects.

regards,
David

 
 
 

1. Mixing GDI, OpenGL, QT

I'm starting with an effort to integrate OpenGL with our project.

On the Windows side, when I use OpenGL to draw into a rectangle in a
window that also has GDI graphics and text being drawn there tho offset
by some pixels so that they don't overlap, scrolling the window content
up and down causes the GDI graphics and text to break up as if it isn't
being updated properly, or updated in the right place. The phenom
appears related to using the SetPixelFormat() command; I'm not using
double buffers as per the MS doc on opengl. Note that there is a bit of
QTML driving some offscreen pixmap copying to the view.

Has anyone seen this sort of behavior?

2. Almost Real Water with LW (24KB binary here - image)

3. Mixing OpenGL with GDI (BitBlt)

4. need a 3ds->vrml converter that REALLY WORKS

5. feedback on OpenGL + GDI mixing please

6. laptop vga

7. Excellent demo of OpenGL rendering + mixing with GDI

8. Mixing double buffered OpenGL and Windows GDI graphics (on Win NT)

9. Mixing OpenGL and the windows GDI

10. Mixing OpenGL and the Windows GDI

11. Problems with OpenGL and GDI mixing.

12. autoredraw and gdi+