Bug in SimpleGraph ???

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

Bug in SimpleGraph ???

Postby P_G » June 14th, 2004, 11:21 am

SimpleGraph 1.21

First of all: Congratulations for this great component. It's very useful and stable.
But I noticed a bug in the new zoom-feature (or at least I think it's a bug): If the node contains a graphic, this graphic is not displayed properly when zooming. It seems theres a problem with the bounding-box. :shock:

C.U. P_G
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany

Postby Kambiz » June 14th, 2004, 1:15 pm

I couldn't regenerate the case.

Could you please attach a screenshot and its associated sgp file?
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Sorry !!!

Postby P_G » June 14th, 2004, 2:39 pm

Sorry, Kambiz.
My fault - there's no bug in displaying graphics while zooming. The problem ocurred because I modificated the procedure TGraphNode.DrawBackground to use Metafiles instead of Bitmaps in graphics. This caused the bug I referred to (so I produced this bug by myself). :oops:
Nevertheless I do not have success in implementing this feature: I need the possibility of attaching a metafile or a bitmap into the node's picture.
Do you have any ideas?

C.U. P_G
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany

Postby Kambiz » June 14th, 2004, 5:36 pm

The Background property of TGraphNode is TPicture. So, it can be assigned or loaded by any Delphi supported image format (Bitmap, Icon, JPEG, Metafile).

Code: Select all
if SimpleGraph.Objects[I] is TGraphNode then
  TGraphNode(SimpleGraph.Objects[I]).Background.LoadFromFile('D:\Sample.wmf');

Code: Select all
if SimpleGraph.Objects[I] is TGraphNode then
  TGraphNode(SimpleGraph.Objects[I]).Background := Image1.Picture;

Code: Select all
if SimpleGraph.Objects[I] is TGraphNode then
  TGraphNode(SimpleGraph.Objects[I]).Background.Assign(AMetafile);

Code: Select all
if SimpleGraph.Objects[I] is TGraphNode then
  TGraphNode(SimpleGraph.Objects[I]).Background.Graphic := ABitmap;
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Yip, I know this.

Postby P_G » June 15th, 2004, 7:58 am

Kambiz wrote:The Background property of TGraphNode is TPicture. So, it can be assigned or loaded by any Delphi supported image format (Bitmap, Icon, JPEG, Metafile).


This is true of course. There's only the problem that the DrawBackGround-procedure converts the Metafile to a Bitmap. So if you stretch the node, you can see the pixels of the graphic. To avoid this effect I tried to change the DrawBackGround to work with Metafiles (Stretch instead of StretchBLT). This worked fine but caused the discribed bug in the new version. :cry:
Any help of you would be apreciated.

C.U. P_G
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany

Postby Kambiz » June 15th, 2004, 9:12 am

Some printer drivers only accept DIB bitmaps to draw on their canvas. Althought, for a metafile that doesn't contain a DDB bitmap there's no problem. However, the code is written in a general manner.
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Interesting ...

Postby P_G » June 15th, 2004, 9:26 am

Hi Kambiz,

Actually I didn't check printer results. I just saw the results on the monitor and it was a matter of quality for me. Is there no way to implement a workaround for the StretchBLT so that vectorgraphics are displayed properly on the monitor and the zoomfunction stills works correct? :(

C.U. P_G
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany

Postby Kambiz » June 15th, 2004, 3:08 pm

The following code may help you.

Code: Select all
procedure TGraphNode.DrawBackground(Canvas: TCanvas);
var
  Rgn: HRGN;
begin
  if (Background.Graphic <> nil) and (Background.Graphic is TMetaFile) then
  begin
    Rgn := CreateTargetRegion(Canvas);
    try
      SelectClipRgn(Canvas.Handle, Rgn);
    finally
      DeleteObject(Rgn);
    end;
    try
      PlayEnhMetaFile(Canvas.Handle, TMetaFile(Background.Graphic).Handle, BoundsRect);
    finally
      SelectClipRgn(Canvas.Handle, 0);
    end;
    Canvas.Brush.Style := bsClear;
  end;
end;
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Fantastic !!!

Postby P_G » June 15th, 2004, 3:20 pm

Thanks alot, Kambiz !
:D :D :D
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron