| View previous topic :: View next topic |
| Author |
Message |
P_G Member
Joined: 14 Jun 2004 Posts: 21 Location: Germany
|
Posted: 14/06/04 11:21 Post subject: Bug in SimpleGraph ??? |
|
|
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.
C.U. P_G |
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 413 Location: Tehran, Iran
|
Posted: 14/06/04 13:15 Post subject: |
|
|
I couldn't regenerate the case.
Could you please attach a screenshot and its associated sgp file? |
|
| Back to top |
|
 |
P_G Member
Joined: 14 Jun 2004 Posts: 21 Location: Germany
|
Posted: 14/06/04 14:39 Post subject: Sorry !!! |
|
|
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).
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 |
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 413 Location: Tehran, Iran
|
Posted: 14/06/04 17:36 Post subject: |
|
|
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: | if SimpleGraph.Objects[I] is TGraphNode then
TGraphNode(SimpleGraph.Objects[I]).Background.LoadFromFile('D:\Sample.wmf'); |
| Code: | if SimpleGraph.Objects[I] is TGraphNode then
TGraphNode(SimpleGraph.Objects[I]).Background := Image1.Picture; |
| Code: | if SimpleGraph.Objects[I] is TGraphNode then
TGraphNode(SimpleGraph.Objects[I]).Background.Assign(AMetafile); |
| Code: | if SimpleGraph.Objects[I] is TGraphNode then
TGraphNode(SimpleGraph.Objects[I]).Background.Graphic := ABitmap; |
|
|
| Back to top |
|
 |
P_G Member
Joined: 14 Jun 2004 Posts: 21 Location: Germany
|
Posted: 15/06/04 07:58 Post subject: Yip, I know this. |
|
|
| 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.
Any help of you would be apreciated.
C.U. P_G |
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 413 Location: Tehran, Iran
|
Posted: 15/06/04 09:12 Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
P_G Member
Joined: 14 Jun 2004 Posts: 21 Location: Germany
|
Posted: 15/06/04 09:26 Post subject: Interesting ... |
|
|
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 |
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 413 Location: Tehran, Iran
|
Posted: 15/06/04 15:08 Post subject: |
|
|
The following code may help you.
| Code: | 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; |
|
|
| Back to top |
|
 |
P_G Member
Joined: 14 Jun 2004 Posts: 21 Location: Germany
|
Posted: 15/06/04 15:20 Post subject: Fantastic !!! |
|
|
Thanks alot, Kambiz !
|
|
| Back to top |
|
 |
|