Board index » delphi » Ho to do an Interface (TV lines) effect?

Ho to do an Interface (TV lines) effect?

Hi,

After learning Delphi 5 for a while, I'm beginning to explore on the
graphics portion. A question - how do I create an interlace (TV lines)
effect on a TBitmap, and how can I vary the thickness of the lines, and the
'distance' between the lines.  Any help would be great!

Rgds
Ron

 

Re:Ho to do an Interface (TV lines) effect?


Quote
> how do I create an interlace (TV lines) effect on a TBitmap

The easiest version would be

Bitmap.Canvas.Pen.Color := clBlack;
y := 0;
while y < Bitmap.Height do begin
  Bitmap.Canvas.MoveTo (0,y);
  Bitmap.Canvas.LineTo (Bitmap.Width,y);
  inc (y,2);
end;

Probably you want the lines not to be completely black but just a bit
darker. I recommend to use the ScanLine property (on a 24 or 32 bit
bitmap), do basically the same as above, but use a pointer that steps
through the lines and does something like Ptr^.Red := Ptr^.Red DIV 2
etc. (more on ScanLines can be found on
http://www.efg2.com/Lab/ImageProcessing/Scanline.htm)

Quote
> and how can I vary the thickness of the lines, and the
> 'distance' between the lines.

inc (y,3) instead of (inc (y,2) makes the distance greater, for thicker
lines simply draw several ones directly after one another.

Jens

Re:Ho to do an Interface (TV lines) effect?


Hi Jens,

Thanks a lot.   I tried using another method of changing 'even' lines to
clBlack, and not touching the odd lines.  It worked like a standard
interlaced image.. but your method allows changing pen size.. which is what
I would like to do... Will explore your method as suggested.

Rgds
Ron

Quote
"Jens Gruschel" <j...@pegtop.net> wrote in message

news:3C0AB8C6.6DA00175@pegtop.net...
Quote
> > how do I create an interlace (TV lines) effect on a TBitmap

> The easiest version would be

> Bitmap.Canvas.Pen.Color := clBlack;
> y := 0;
> while y < Bitmap.Height do begin
>   Bitmap.Canvas.MoveTo (0,y);
>   Bitmap.Canvas.LineTo (Bitmap.Width,y);
>   inc (y,2);
> end;

> Probably you want the lines not to be completely black but just a bit
> darker. I recommend to use the ScanLine property (on a 24 or 32 bit
> bitmap), do basically the same as above, but use a pointer that steps
> through the lines and does something like Ptr^.Red := Ptr^.Red DIV 2
> etc. (more on ScanLines can be found on
> http://www.efg2.com/Lab/ImageProcessing/Scanline.htm)

> > and how can I vary the thickness of the lines, and the
> > 'distance' between the lines.

> inc (y,3) instead of (inc (y,2) makes the distance greater, for thicker
> lines simply draw several ones directly after one another.

> Jens

Re:Ho to do an Interface (TV lines) effect?


Quote
> Thanks a lot.   I tried using another method of changing 'even' lines to
> clBlack, and not touching the odd lines.

The Even-Odd-Method brought me to an idea (even-odd is nothing but y MOD
2 = 0/1). This one is easier to cope with...

Bitmap.Canvas.Pen.Color := clBlack;
y := 0;
while y < Bitmap.Height do begin
  if (y MOD (SpaceBetweenLine+LineThickness)) < LineThickness then begin
    Bitmap.Canvas.MoveTo (0,y);
    Bitmap.Canvas.LineTo (Bitmap.Width,y);
  end;
  inc (y,1);
end;

Jens

Re:Ho to do an Interface (TV lines) effect?


Jens,

Yes... and by making the Pen.Color a variable, you'll have a VENETIAN BLIND
filter!. This is great.... :)

Rgds
Ronnie

Quote
"Jens Gruschel" <j...@pegtop.net> wrote in message

news:3C0C1F97.9300A6AF@pegtop.net...
Quote
> > Thanks a lot.   I tried using another method of changing 'even' lines to
> > clBlack, and not touching the odd lines.

> The Even-Odd-Method brought me to an idea (even-odd is nothing but y MOD
> 2 = 0/1). This one is easier to cope with...

> Bitmap.Canvas.Pen.Color := clBlack;
> y := 0;
> while y < Bitmap.Height do begin
>   if (y MOD (SpaceBetweenLine+LineThickness)) < LineThickness then begin
>     Bitmap.Canvas.MoveTo (0,y);
>     Bitmap.Canvas.LineTo (Bitmap.Width,y);
>   end;
>   inc (y,1);
> end;

> Jens

Other Threads