Bitmap or Image

J

Jon Slaughter

Whats is there any reason to use a Bitmap(Image) over an Image(Bitmap)? I'm
making a container to hold bitmaps sorta like the ImageList class(that
doesn't fix the sizes) but I'm not sure if I should use Images or Bitmaps?
I don't know of the real distinction between them excep that the Bitmap
class allows you lower level access to the image data and stuff(but does it
come at a price)?

Thanks,
Jon
 
M

Morten Wennevik

Hi Jon,

Image is an abstract class, and the base class for MetaFile and Bitmap.

I'd use Bitmap as everything the Image can do, Bitmap can do as well.
Since Bitmap inherits from Image, all places expecting an Image object can
take a Bitmap object.
 
M

Michael C

Jon Slaughter said:
Whats is there any reason to use a Bitmap(Image) over an Image(Bitmap)?
I'm making a container to hold bitmaps sorta like the ImageList class(that
doesn't fix the sizes) but I'm not sure if I should use Images or Bitmaps?
I don't know of the real distinction between them excep that the Bitmap
class allows you lower level access to the image data and stuff(but does
it come at a price)?

Image is the base class and is inherited by Bitmap and Metafile. If you wish
to support both Bitmaps and Metafiles then use Image. If you only want to
use Bitmaps then use Bitmap, there won't be any overhead as the object will
be a bitmap anyway.

Michael
 
M

Marc Gravell

Well, Image is the abstract base class of Bitmap. Having a list of
Images does mean that theoretically you can handle /any/ Image
implementation, but there aren't many... in the core MS libraries this
is just Bitmap and Metafile (IIRC), although in reality Bitmap is by
far the more common. If you only need to handle Bitmap, then a list of
Bitmaps should be fine, and save some casting. If you don't need the
extra Bitmp properties, then use Image.
but does it come at a price

No; since Image is abstract, you cannot have just an Image; typically
you have a Bitmap, but treat it like the base Image; but it is still a
Bitmap ;-p. In terms of storage in your class, it is still just a
pointer to the heap, so identical.

Marc
 
J

Jon Slaughter

Ok, Thanks guys. I would like to use both an image and metafile since it
offers a more robust solution. I play around with it and see what happens.
Basically I'm trying to setup a button that displays a user defined set of
images depending on the state. Obviously bitmaps are nice but not always
needed and vector graphics are simple and tend to offer an easier
implementation(such as what the OS already uses). It seems much easier just
to create teh metafile with some external program and load it instead of
using a bunch of graphics commands to draw it. (but I suppose I can just
keep a list of images that represent the state and draw them using DrawImage
and not worry to much about the underlying type)


Thanks,
Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top