Board index » delphi » Line "sweep" drawing on Images

Line "sweep" drawing on Images

All:

I'm having difficulty with a simple graphic action.  I have a sweeping
line (which "sweeps" by erasing its last position).  This works fine,
but when I use an image as the canvas on which to do it, (with
Pen.Mode = pmNotXOR) I get funky colors.  I want a solid line.  I've
tried all pen modes, but none work.  (Yes - solid line is pmSolid -
but you can't erase that way!)

Any help is greatly appreciated.

Thanks!

Mark

 

Re:Line "sweep" drawing on Images


Quote
In article <349d531d.33797...@news.mindspring.com> mle...@NOSPAMmindspring.com (Mark Lerch) writes:
>I'm having difficulty with a simple graphic action.  I have a sweeping
>line (which "sweeps" by erasing its last position).  This works fine,
>but when I use an image as the canvas on which to do it, (with
>Pen.Mode = pmNotXOR) I get funky colors.  I want a solid line.  I've
>tried all pen modes, but none work.  (Yes - solid line is pmSolid -
>but you can't erase that way!)

Doing an XOR on a bitmap inverts the bits of all the colors; it doesn't simply
set black to white or white to black, it sets RGB(2,16,244) to RGB(253,239,11)
and so on.

What you would need to do, probably, is to make a snapshot image of the
original bitmap and restore the line by drawing from the original bitmap.

Re:Line "sweep" drawing on Images


Thanks for the reply.  I was afraid of that.

My next question would be how to control the {*word*193} flicker on a 256
color bitmap as the line is continually replaced?

Thanks for any help.

On 21 Dec 1997 08:38:00 -0700, news-re...@sundialservices.com (Sundial

Quote
Services) wrote:
>In article <349d531d.33797...@news.mindspring.com> mle...@NOSPAMmindspring.com (Mark Lerch) writes:

>>I'm having difficulty with a simple graphic action.  I have a sweeping
>>line (which "sweeps" by erasing its last position).  This works fine,
>>but when I use an image as the canvas on which to do it, (with
>>Pen.Mode = pmNotXOR) I get funky colors.  I want a solid line.  I've
>>tried all pen modes, but none work.  (Yes - solid line is pmSolid -
>>but you can't erase that way!)

>Doing an XOR on a bitmap inverts the bits of all the colors; it doesn't simply
>set black to white or white to black, it sets RGB(2,16,244) to RGB(253,239,11)
>and so on.

>What you would need to do, probably, is to make a snapshot image of the
>original bitmap and restore the line by drawing from the original bitmap.

Re:Line "sweep" drawing on Images


This seems to work (works for me), unless I misunderstand the problem....

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  OldX := x;
  OldY := y;
  CurX := x;
  CurY := y;
  Bounding := true;
end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if Bounding then
  begin
   Image1. Canvas.Brush.Style := bsClear;
   Image1. Canvas.Pen.Style := psSolid;
   Image1. Canvas.Pen.Mode := pmNot;
   Image1. Canvas.Rectangle(OldX,OldY,CurX,CurY);
    CurX := x; CurY := y;
    Image1.Canvas.Rectangle(OldX,OldY,CurX,CurY);
  end;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Bounding then
 begin
    Bounding := false;
    Image1.Canvas.Brush.Style := bsClear;
    Image1.Canvas.Pen.Mode := pmNot;
    Image1.Canvas.Rectangle(OldX,OldY,CurX,CurY);
 end;  
end;

Quote
>I'm having difficulty with a simple graphic action.  I have a sweeping
>line (which "sweeps" by erasing its last position).  This works fine,
>but when I use an image as the canvas on which to do it, (with
>Pen.Mode = pmNotXOR) I get

Chris
c8591@~despammer~aol.com

Re:Line "sweep" drawing on Images


Thank you Chris, I will try this code immediately when I get to work
this AM.....(doesn't look much different from mine, but I'll figure
out where my flicker was coming from ...)

Have a great day.

On 23 Dec 1997 07:12:01 GMT, c8...@aol.com (C8591) wrote:

Quote
>This seems to work (works for me), unless I misunderstand the problem....

>procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
>  Shift: TShiftState; X, Y: Integer);
>begin
>  OldX := x;
>  OldY := y;
>  CurX := x;
>  CurY := y;
>  Bounding := true;
>end;

>procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
>  Y: Integer);
>begin
>  if Bounding then
>  begin
>   Image1. Canvas.Brush.Style := bsClear;
>   Image1. Canvas.Pen.Style := psSolid;
>   Image1. Canvas.Pen.Mode := pmNot;
>   Image1. Canvas.Rectangle(OldX,OldY,CurX,CurY);
>    CurX := x; CurY := y;
>    Image1.Canvas.Rectangle(OldX,OldY,CurX,CurY);
>  end;
>end;

>procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
>  Shift: TShiftState; X, Y: Integer);
>begin
>  if Bounding then
> begin
>    Bounding := false;
>    Image1.Canvas.Brush.Style := bsClear;
>    Image1.Canvas.Pen.Mode := pmNot;
>    Image1.Canvas.Rectangle(OldX,OldY,CurX,CurY);
> end;  
>end;

>>I'm having difficulty with a simple graphic action.  I have a sweeping
>>line (which "sweeps" by erasing its last position).  This works fine,
>>but when I use an image as the canvas on which to do it, (with
>>Pen.Mode = pmNotXOR) I get

>Chris
>c8591@~despammer~aol.com

Re:Line "sweep" drawing on Images


This simply fiddles with the bits.  I want to draw a solid, (heavy)
line - save/restore the background.  Thanks!

On 23 Dec 1997 07:12:01 GMT, c8...@aol.com (C8591) wrote:

Quote
>This seems to work (works for me), unless I misunderstand the problem....

>procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
>  Shift: TShiftState; X, Y: Integer);
>begin
>  OldX := x;
>  OldY := y;
>  CurX := x;
>  CurY := y;
>  Bounding := true;
>end;

>procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
>  Y: Integer);
>begin
>  if Bounding then
>  begin
>   Image1. Canvas.Brush.Style := bsClear;
>   Image1. Canvas.Pen.Style := psSolid;
>   Image1. Canvas.Pen.Mode := pmNot;
>   Image1. Canvas.Rectangle(OldX,OldY,CurX,CurY);
>    CurX := x; CurY := y;
>    Image1.Canvas.Rectangle(OldX,OldY,CurX,CurY);
>  end;
>end;

>procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
>  Shift: TShiftState; X, Y: Integer);
>begin
>  if Bounding then
> begin
>    Bounding := false;
>    Image1.Canvas.Brush.Style := bsClear;
>    Image1.Canvas.Pen.Mode := pmNot;
>    Image1.Canvas.Rectangle(OldX,OldY,CurX,CurY);
> end;  
>end;

>>I'm having difficulty with a simple graphic action.  I have a sweeping
>>line (which "sweeps" by erasing its last position).  This works fine,
>>but when I use an image as the canvas on which to do it, (with
>>Pen.Mode = pmNotXOR) I get

>Chris
>c8591@~despammer~aol.com

Other Threads