ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Dashed/dotted line object using TImageEnVect
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
234 Posts

Posted - Sep 03 2015 :  07:19:54  Show Profile  Reply
Hi

Is it possible to draw a dashed or dotted line as an object when using a TImageEnVect component? I have no problem drawing a continuous line using iekLINE object kind.

Bruce.

xequte

39053 Posts

Posted - Sep 03 2015 :  16:20:27  Show Profile  Reply
Sure, use something like:

ImageEnVect1.ObjPenStyle[ IEV_NEXT_INSERTED_OBJECT ] := psDot;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

bmesser

United Kingdom
234 Posts

Posted - Sep 21 2015 :  06:14:26  Show Profile  Reply
Thanks Nigel.

I couldn't find any documentation on that and I can't see the source.
Go to Top of Page

bmesser

United Kingdom
234 Posts

Posted - Sep 21 2015 :  06:36:58  Show Profile  Reply
That didn't work here's what I'm trying to do:

with Image.BackBuffer.Canvas do
  begin
    // Draw lines of latitude
    y:=0;

    while y<=Image.IEBitmap.Height do
    begin
      ndx:=Image.AddNewObject;
      Image.ObjKind[ndx]     := iekLINE;
      Image.ObjLeft[ndx]     := 0;
      Image.ObjTop[ndx]      := y;
      Image.ObjWidth[ndx]    := Image.IEBitmap.Width;
      Image.ObjHeight[ndx]   := 0;
      Image.ObjPenColor[ndx] := clBlack;
      Image.ObjPenStyle[ndx] := psDot;

      inc(y,200);
    end;


Am I using the wrong object kind?

Bruce.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 21 2015 :  17:55:24  Show Profile  Reply
I do not think using objects to show latitude lines is very efficient or appropriate. I'd draw the lines on a transparent layer instead...

Add iexhelperfunctions, iegdiplus to uses of DrawLayers Demo then add this:

procedure Tfmain.DrawLine(X: Integer; Y: Integer);
{ Draw a line. }
var
  iPenSize: Integer;
  iPenColor: TColor;
  iPenAlpha: Integer;
  iIECanvas: TIECanvas;
begin
  { Draw on the Non-Alpha Canvas }
  iIECanvas := TIECanvas.Create(ImageEnView1.IEBitmap.Canvas, false, false);
  iPenSize := 1;
  iPenColor := clBlack;
  iPenAlpha := 255;
  iIECanvas.Pen.Color := iPenColor;
  iIECanvas.Pen.Mode := pmNotXor;
  iIECanvas.Pen.Style := psDot;
  iIECanvas.Pen.Width := iPenSize;
  iIECanvas.Brush.Color := clBlack;
  iIECanvas.Brush.BackColor := clBlack;
  iIECanvas.Brush.Style := bsClear;
  iIECanvas.Brush.Transparency := 255;
  iIECanvas.MoveTo(X, Y);
  iIECanvas.LineTo(ImageEnView1.Bitmap.Width, Y);
  iIECanvas.Free();
  { Draw on the Alpha Canvas - do not assign color here... it will overwrite
    the alphachannel }
  ImageEnView1.IEBitmap.AlphaChannel.CanvasCurrentAlpha := iPenAlpha;
  iIECanvas := TIECanvas.Create(ImageEnView1.IEBitmap.AlphaChannel.Canvas,
    false, false);
  iIECanvas.Pen.Width := iPenSize;
  iIECanvas.Pen.Style := psDot;
  iIECanvas.Pen.Transparency := 255;
  iIECanvas.Brush.Transparency := 0;
  iIECanvas.MoveTo(X, Y);
  iIECanvas.LineTo(ImageEnView1.Bitmap.Width, Y);
  iIECanvas.Free();
end;

procedure Tfmain.DrawLatitude1Click(Sender: TObject);
var
  iLayer: Integer;
  Y: Integer;
begin
  { Add a layer }
  iLayer := ImageEnView1.LayersAdd;
  ImageEnView1.LayersCurrent := iLayer;
  ImageEnView1.CurrentLayer.name := 'Latitiude Layer';
  ImageEnView1.CurrentLayer.PosX := 0;
  ImageEnView1.CurrentLayer.PosY := 0;
  ImageEnView1.CurrentLayer.VisibleBox := True;
  ImageEnView1.CurrentLayer.Selectable := True;
  ImageEnView1.LayersDrawBox := True;
  ImageEnView1.CurrentLayer.Cropped := True;
  ImageEnView1.CurrentLayer.Width := ImageEnView1.Bitmap.Width;
  ImageEnView1.CurrentLayer.Height := ImageEnView1.Bitmap.Height;
  { Render a transparent layer }
  ImageEnView1.Proc.SetTransparentColors(ImageEnView1.Layers[iLayer]
    .Bitmap.Pixels[0, ImageEnView1.Layers[iLayer].Bitmap.Height - 1],
    ImageEnView1.Layers[iLayer].Bitmap.Pixels[0,
    ImageEnView1.Layers[iLayer].Bitmap.Height - 1], 0);
  Y := 0;
  while Y <= ImageEnView1.IEBitmap.Height do
  begin
    // Draw horzontal lines
    if Y <> 0 then
    DrawLine(0, Y);
    inc(Y, 200);
  end;
end;


Change the line appearance by changing the iIECanvas.Pen.Mode and iIECanvas.Pen.Width values to adjust visibility depending on the dimensions of the bitmap and the line and zooming. The following image was produced by merging the latitude layer with the image with ImageEnView1.LayersMergeAll(true), then the image was saved to a file with the Layers demo...

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development

Go to Top of Page

xequte

39053 Posts

Posted - Sep 22 2015 :  00:15:22  Show Profile  Reply
Also, Bruce, looks like you are setting the ObjHeight to zero.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: