Extract a single image from a PNG file containing multiple images

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Wondering if someone might be able to point me at some documentation
to extract an image from a PNG file found in the VS2008 Image Library.

Example:

Edit.png contains five different images of the pencil. I want to
extract a single image from it but keep the integrity of the file.

Thanks
 
Wondering if someone might be able to point me at some documentation
to extract an image from a PNG file found in the VS2008 Image Library.

Example:

Edit.png contains five different images of the pencil. I want to
extract a single image from it but keep the integrity of the file.

The PNG file doesn't contain five images, not in the sense that an animated
GIF contains multiple images. It merely contains 5 LOGICAL images, meaning
that, for example, it's 16 x 80, and the area from 0 - 15 (Y values) has one
logical image, 16 - 31 has another, and so one. What you're looking to do is
simply use one of these 16 x 16 chunks, and for that you'll need a couple of
things:

1) Some 2nd- or 3rd-grade math.

2) Either the Bitmap.Clone() overload which allows you to specify the
rectangle you want to use as the source of the clone or the
Graphics.DrawImage() overload which allows for a similar thing. Which you
choose depends on whether you're trying to create a new bitmap or just draw
the bitmap.
 
Back
Top