class Image
-
Hi I am beginner at C#. I need to create two classes which will represent two picture models(like JPG and bitmap).It should look something like this class JPGImage { .............. } class BMPImage { .............. } I don't know how to describe this classes. In winForm I need 2 panels where I'll put this 2 models. Can you help me with this? Thanks
-
Hi I am beginner at C#. I need to create two classes which will represent two picture models(like JPG and bitmap).It should look something like this class JPGImage { .............. } class BMPImage { .............. } I don't know how to describe this classes. In winForm I need 2 panels where I'll put this 2 models. Can you help me with this? Thanks
It depends what you want to do. In .NET, you use the Bitmap class to handle not only BMP images but also GIF, PNG and JPG - so from most points of view there would be no difference as to what members you would use to describe them.
-
It depends what you want to do. In .NET, you use the Bitmap class to handle not only BMP images but also GIF, PNG and JPG - so from most points of view there would be no difference as to what members you would use to describe them.
-
OK thanks, Does it mean that I can inherit from Bitmap class my class like this : class JpgImage : Bitmap { .... } and create object JpgImage? Which methods I can use for working with my class (class JpgImage)?
videhr wrote:
Does it mean that I can inherit from Bitmap class my class like this :
No. the Bitmap class is
sealed
, which means you can't inherit from it. You'd either need to use the Bitmap class, entirely write your own JpgImage class or use a mixture (a JpgImage class which uses a Bitmap instance and its methods) regards -
videhr wrote:
Does it mean that I can inherit from Bitmap class my class like this :
No. the Bitmap class is
sealed
, which means you can't inherit from it. You'd either need to use the Bitmap class, entirely write your own JpgImage class or use a mixture (a JpgImage class which uses a Bitmap instance and its methods) regards -
Thanks, i am starting to understand this. Using this mixture should look like this: Image JpgImage= new Bitmap("image1.jpg"); am I right?
-
I acutually thought about something like this:
class JpgImage
{
private Bitmap jpg;public JpgImage(string file) { jpg = new Bitmap(file); }
}
-
I'm not sure I understand this,but it is ok. Now with jpg I can create drawing(like rectangular or elipse,line etc),am I right? Thank you again,you have helped me a lot. Sorry for bothering you.
-
I acutually thought about something like this:
class JpgImage
{
private Bitmap jpg;public JpgImage(string file) { jpg = new Bitmap(file); }
}
whats the point though? they all load in exactly the same way from Bitmap, no advantages / disadvantages from what you can do with them - just use the Bitmap class, or if you have to public enum ImageType { JPG = 0; PNG = 1; etc } class Image { public bitmap itsBitmap; public ImageType itsFormat; }