Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
jvv  
#1 Posted : Thursday, October 14, 2004 6:15:00 PM(UTC)
jvv

Rank: Member

Groups: Member
Joined: 10/14/2004(UTC)
Posts: 37

I want to make a crop mask like the example in VB, the difference is that I'm using Delphi.
I translated the Visual Basic code to Delphi code:
Code:

procedure TMainForm.TiffViewerDoubleBufferPaint(ASender: TObject;
  Hdc: Cardinal);
var X1, Y1, X2, Y2: Integer;
begin
  if (TiffViewer.SelectionWidth > 0) and (TiffViewer.SelectionHeight > 0) then
  begin
      //'Attach graphics object to temporary device context
      //'which is used for double buffer painting


      TiffViewer.Bitmap.Graphics.Engine := DrawingEngineGdiplus;
      TiffViewer.Bitmap.Graphics.Antialiasing := False;
      TiffViewer.Bitmap.Graphics.Brush.PrimaryColor := $80FF0000;

    //'To shade a part of image which should be cropped,
    //  'we will draw four semi-transparent rectangles.

    //'Draw top part
    //  'Convert bitmap coordinates to control and draw a top rectangle
      TiffViewer.BitmapToControlCoords(0, 0, X1, Y1);
      TiffViewer.BitmapToControlCoords(TiffViewer.Bitmap.Data.Width, TiffViewer.SelectionTop, X2, Y2);
      TiffViewer.Bitmap.Graphics.DrawRectangle(X1, Y1, X2 - X1, Y2 - Y1, False, False, 0);

    //  'Draw bottom part
    // 'Convert bitmap coordinates to control and draw a bottom rectangle
      TiffViewer.BitmapToControlCoords(0, TiffViewer.SelectionTop + TiffViewer.SelectionHeight, X1, Y1);
      TiffViewer.BitmapToControlCoords(TiffViewer.Bitmap.Data.Width, TiffViewer.Bitmap.Data.Height, X2, Y2);
      TiffViewer.Bitmap.Graphics.DrawRectangle(X1, Y1, X2 - X1, Y2 - Y1, True, False, 0);
    //  'Draw left part
    //  'Convert bitmap coordinates to control and draw a left rectangle
      TiffViewer.BitmapToControlCoords(0, TiffViewer.SelectionTop, X1, Y1);
      TiffViewer.BitmapToControlCoords(TiffViewer.SelectionLeft, TiffViewer.SelectionTop + TiffViewer.SelectionHeight, X2, Y2);
      TiffViewer.Bitmap.Graphics.DrawRectangle(X1, Y1, X2 - X1, Y2 - Y1, True, False, 0);
    //  'Draw right part
    //  'Convert bitmap coordinates to control and draw a right rectangle
      TiffViewer.BitmapToControlCoords(TiffViewer.SelectionLeft + TiffViewer.SelectionWidth, TiffViewer.SelectionTop, X1, Y1);
      TiffViewer.BitmapToControlCoords(TiffViewer.Bitmap.Data.Width, TiffViewer.SelectionTop + TiffViewer.SelectionHeight, X2, Y2);
      TiffViewer.Bitmap.Graphics.DrawRectangle(X1, Y1, X2 - X1, Y2 - Y1, True, False, 0);
  end;
end;


When I compile, I don't get any error.
But when I try to draw a selection rectangle, I get an error:

[Image was removed]

I mostly use TIFF image's.

Thanks in advance...

Edited by user Friday, December 18, 2009 8:37:55 PM(UTC)  | Reason: Not specified

Andrew  
#2 Posted : Thursday, October 14, 2004 9:18:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Please check the neighbour post.
Users browsing this topic
Similar Topics
Crop Mask Sample (Other Products)
by Fedor 12/3/2003 9:08:00 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.