I have a design question…
I want to create my own image class called EfficientImage which will include a Load which will take a System.Drawing.Bitmap and use lock bits to convert it into a 2D byte array.
class EfficientImage
{
private byte[,] image;
private int width;
private int height;
public Load(System.Drawing.Bitmap inImage)
{
}
//etc...
}
so i might have
EfficentImage ef = new EfficientImage();
ef.Load(myBitmap);
What is the best way to access the image array within the object without losing the performance gain of using LockBits in the first place? I believe having an accessor or a property would be replicating the GetPixel/SetPixel in a normal Bitmap object which is not efficient and setting the image field to public would break encapsulation
It may be that this design is entirely the wrong way to go but I would be very pleased to learn of a better/correct way.
Thanks for your help
I assume you want to apply some kind of filter to images, or have some other kind of processing that modifies multiple pixels.
If that is the case, I would call your class something like
ImageFilter, for instance:That way you can write custom filters that deal with the raw data only, while the
ImageFilterabstract class deals with loading the image and its data.Apologies if I missed the point 🙂