Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. class Image

class Image

Scheduled Pinned Locked Moved C#
csharpgraphicshelptutorialquestion
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    videhr
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • V videhr

      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

      J Offline
      J Offline
      James Gupta
      wrote on last edited by
      #2

      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.

      V 1 Reply Last reply
      0
      • J James Gupta

        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.

        V Offline
        V Offline
        videhr
        wrote on last edited by
        #3

        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)?

        L 1 Reply Last reply
        0
        • V videhr

          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)?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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

          V 1 Reply Last reply
          0
          • L Lost User

            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

            V Offline
            V Offline
            videhr
            wrote on last edited by
            #5

            Thanks, i am starting to understand this. Using this mixture should look like this: Image JpgImage= new Bitmap("image1.jpg"); am I right?

            L 1 Reply Last reply
            0
            • V videhr

              Thanks, i am starting to understand this. Using this mixture should look like this: Image JpgImage= new Bitmap("image1.jpg"); am I right?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I acutually thought about something like this:

              class JpgImage
              {
              private Bitmap jpg;

              public JpgImage(string file)
              {
                  jpg = new Bitmap(file);
              }
              

              }

              V J 2 Replies Last reply
              0
              • L Lost User

                I acutually thought about something like this:

                class JpgImage
                {
                private Bitmap jpg;

                public JpgImage(string file)
                {
                    jpg = new Bitmap(file);
                }
                

                }

                V Offline
                V Offline
                videhr
                wrote on last edited by
                #7

                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.

                L 1 Reply Last reply
                0
                • V videhr

                  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.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  videhr wrote:

                  Now with jpg I can create drawing(like rectangular or elipse,line etc),am I right?

                  No you can't. Sorry no offense, but I think you need to read a book about C# and take a lot of practice to understand how this stuff works regards

                  1 Reply Last reply
                  0
                  • L Lost User

                    I acutually thought about something like this:

                    class JpgImage
                    {
                    private Bitmap jpg;

                    public JpgImage(string file)
                    {
                        jpg = new Bitmap(file);
                    }
                    

                    }

                    J Offline
                    J Offline
                    James Gupta
                    wrote on last edited by
                    #9

                    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; }

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups