Board index » delphi » Cut away blank area of picture

Cut away blank area of picture

I have a grey scale picture loaded into a TPicture,
can somebody post a sample code how to determine roughly the wanted
area is (assuming say, grey value <20 is blank)

And how to cut away the unwanted area (cropping) or extract the wanted
part.

Many thanks.

 

Re:Cut away blank area of picture


Quote
Anders LEE wrote in message <36343045.1033...@forums.borland.com>...

>I have a grey scale picture loaded into a TPicture,
>can somebody post a sample code how to determine roughly the wanted
>area is (assuming say, grey value <20 is blank)

>And how to cut away the unwanted area (cropping) or extract the wanted
>part.

How many bits/pixel is your image?  What is its PixelFormat?

The general answer is to use two nested loops and step through each pixel
in your image:

FOR j := 0 to Bitmap.Height-1 DO
BEGIN
  row := Bitmap.Scanline[ j ];  // Format of Scanline varies with PixelFormat
  FOR i := 0 TO Bitmap.Width-1 DO
  BEGIN
    // test and modify pixel here by using row[ i ]
  END
END

If you could send me a small sample image, I would be willing to send you
more exact code on how to select/reject pixels.

efg
_________________________________________
efg's Computer Lab:  http://infomaster.net/external/efg

Earl F. Glynn                 E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

Other Threads