#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    2
    Rep Power
    0

    Image problems Delphi 6


    I am having difficulty in understanding what is wrong with a section of my program.
    The code is

    Gif:=Tgifimage.Create;
    Bmp:=TBitMap.Create;
    With PaintBox1.Canvas do
    begin
    // outline the cartouche to be saved
    Pen.Width:=1;
    Pen.Style:=psDash;
    MoveTo(0,0);
    LineTo(LineLength+2,0);
    LineTo(LineLength+2,75);
    LineTo(0,75);
    LineTo(0,0);
    // set up Rects
    MyRect:=(Rect(0,0,LineLength+2,75));
    NewRect:=(Rect(0,0,LineLength+2,75));
    // Copy rect from paintbox to Bitmap
    CopyRect(NewRect,PaintBox1.Canvas,MyRect);
    CopyRect(MyRect,Bmp.Canvas,MyRect);
    Gif.Assign(Bmp);
    // just check what has been copied
    PaintBox2.Canvas.Draw(0,200,Gif);
    end;
    The out put is this
    (does not show Pictures here)
    [/IMG]D:\Temp\STA70225.jpg


    The check image on the bottom should be as is on top.
    What have I got wrong to cause the distortion , stretching and mirroring.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    7
    Rep Power
    0
    Your code seems quite confused. Did you write it correctly? The CopyRect calls won't do anything. Firstly you copy from paintbox1 back into paintbox1 and then you copy from bmp into paintbox1, but bmp doesn't have anything in yet. You also haven't set your bmp dimensions. The following works for me, although the assignment to Gif changes the colour at the centre of the rectangle. You can fix that by using a different colour quantization setting in the gifimage options.

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    Var
      Gif : TGifImage;
      Bmp : TBitmap;
      MyRect, NewRect : TRect;
      LineLength : integer;
    begin
      LineLength := 100;
      Gif:=Tgifimage.Create;
      Bmp:=TBitMap.Create;
      Bmp.Width := LineLength + 3;
      Bmp.Height := 76;
      With PaintBox1.Canvas do
      begin
        // outline the cartouche to be saved
        Pen.Width:=1;
        Pen.Style:=psDash;
        MoveTo(0,0);
        LineTo(LineLength+2,0);
        LineTo(LineLength+2,75);
        LineTo(0,75);
        LineTo(0,0);
        // set up Rects
        MyRect:=(Rect(0,0,LineLength+3,76));
        NewRect:=(Rect(0,0,LineLength+3,76));
        // Copy rect from paintbox to Bitmap
        Bmp.Canvas.CopyRect(NewRect,PaintBox1.Canvas,MyRect);
        Gif.Assign(Bmp);
        // just check what has been copied
        PaintBox2.Canvas.Draw(0,200,Gif);
      end;
    end;
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    2
    Rep Power
    0

    Problems with delphi 6 Images


    Thank you for your kind reply I will try again
    GeorgeSpencer7

IMN logo majestic logo threadwatch logo seochat tools logo