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. I need to resize a large image of more than 2MEGABYTE and I can not upload it to the program

I need to resize a large image of more than 2MEGABYTE and I can not upload it to the program

Scheduled Pinned Locked Moved C#
csharpperformancehelptutorial
12 Posts 6 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.
  • G Offline
    G Offline
    gilvani
    wrote on last edited by
    #1

    I have an image of more than 2 megabytes that can not open in any program, so I need to resize it so that any program can open if I could carry it in the program would be easy but it has an error OUT OF MEMORY someone tell me how to resize the image without loading in C Sharp

    L OriginalGriffO 2 Replies Last reply
    0
    • G gilvani

      I have an image of more than 2 megabytes that can not open in any program, so I need to resize it so that any program can open if I could carry it in the program would be easy but it has an error OUT OF MEMORY someone tell me how to resize the image without loading in C Sharp

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, an OOM exception does not always really mean you ran out of memory! Look here[^]. I suggest you first validate your image file by opening it succesfully with one of the reputed image processing programs, such as Adobe Photoshop. :)

      Luc Pattyn

      :badger: :jig: :badger:

      Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

      :jig: :badger: :jig:

      1 Reply Last reply
      0
      • G gilvani

        I have an image of more than 2 megabytes that can not open in any program, so I need to resize it so that any program can open if I could carry it in the program would be easy but it has an error OUT OF MEMORY someone tell me how to resize the image without loading in C Sharp

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        I agree with Luc - I regularly work with images much bigger than 2Meg without problems in C#. I would suspect your code is at fault - try it with a small test image, and it will probably give the same error.

        No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        G 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          I agree with Luc - I regularly work with images much bigger than 2Meg without problems in C#. I would suspect your code is at fault - try it with a small test image, and it will probably give the same error.

          No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

          G Offline
          G Offline
          gilvani
          wrote on last edited by
          #4

          The problem is not in my code is on the image that is a bmp and is a large map and i tried to open the image with Irfanview with Quantum gis and with the Gimp and the Windows can not read the image data. I want to resize the image from the file system and not from the image that appears on the screen. I have not harmed any tree to write this message but have produced a lot of smoke trying to resize the image. Thank's

          D OriginalGriffO 2 Replies Last reply
          0
          • G gilvani

            The problem is not in my code is on the image that is a bmp and is a large map and i tried to open the image with Irfanview with Quantum gis and with the Gimp and the Windows can not read the image data. I want to resize the image from the file system and not from the image that appears on the screen. I have not harmed any tree to write this message but have produced a lot of smoke trying to resize the image. Thank's

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Since nothing is opening it, it would appear that the image file is corrupted or otherwise not in an expected and supported format. Just for giggles, what are the dimensions of the image, in pixels, and the color depth?

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008
            But no longer in 2009...

            G 2 Replies Last reply
            0
            • D Dave Kreskowiak

              Since nothing is opening it, it would appear that the image file is corrupted or otherwise not in an expected and supported format. Just for giggles, what are the dimensions of the image, in pixels, and the color depth?

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008
              But no longer in 2009...

              G Offline
              G Offline
              gilvani
              wrote on last edited by
              #6

              The windows can not give me this data but I made a program that gave me height= 25163 px width = 38180 px rate of bits = 24:cool::cool::thumbsup:

              D D 2 Replies Last reply
              0
              • G gilvani

                The problem is not in my code is on the image that is a bmp and is a large map and i tried to open the image with Irfanview with Quantum gis and with the Gimp and the Windows can not read the image data. I want to resize the image from the file system and not from the image that appears on the screen. I have not harmed any tree to write this message but have produced a lot of smoke trying to resize the image. Thank's

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                I think the problem may be your image then. I regularly deal with images that are in excess of 170Meg without problems, and as a simple test, I just saved one of these as a 8.5Meg .BMP file. In Paint (surely the most basic of basic rubbish image programs), it opens, edits, and saves without problems. I would try with a different image; I suspect yours is not what you think it is.

                No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                G 1 Reply Last reply
                0
                • G gilvani

                  The windows can not give me this data but I made a program that gave me height= 25163 px width = 38180 px rate of bits = 24:cool::cool::thumbsup:

                  D Offline
                  D Offline
                  Dan Neely
                  wrote on last edited by
                  #8

                  That would be more than 2 gigabytes which is a different issue entirely. Adobe editor products will open a file this large in win32; but very little else will. A while back I found a free GIS viewer that would load a monster image but can't recall what it was called. If it's only a one off your least painful option might be to use a liveCD to use the linux version of GIMP to resize it; as of a year ago the win32 version puked on a file that big. I haven't tested under win64, so I don't know if that combo would work any better.

                  The latest nation. Procrastination.

                  1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    Since nothing is opening it, it would appear that the image file is corrupted or otherwise not in an expected and supported format. Just for giggles, what are the dimensions of the image, in pixels, and the color depth?

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008
                    But no longer in 2009...

                    G Offline
                    G Offline
                    gilvani
                    wrote on last edited by
                    #9

                    sorry I was wrong the image is 2.68 gigabytes not 2 megabytes. Can anyone help me? X| X|

                    1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      I think the problem may be your image then. I regularly deal with images that are in excess of 170Meg without problems, and as a simple test, I just saved one of these as a 8.5Meg .BMP file. In Paint (surely the most basic of basic rubbish image programs), it opens, edits, and saves without problems. I would try with a different image; I suspect yours is not what you think it is.

                      No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

                      G Offline
                      G Offline
                      gilvani
                      wrote on last edited by
                      #10

                      sorry I was wrong the image is 2.68 gigabytes not 2 megabytes. Can anyone help me?

                      D 1 Reply Last reply
                      0
                      • G gilvani

                        The windows can not give me this data but I made a program that gave me height= 25163 px width = 38180 px rate of bits = 24:cool::cool::thumbsup:

                        D Offline
                        D Offline
                        Dave Kreskowiak
                        wrote on last edited by
                        #11

                        There is no contorl that is going to load that image. You have to either find a library that will do what you want without loading the image, or write one yourself. Writing one yourself is NOT a trivial task, since you must known what the exact format of the image file is and how to work with the data. Then, you need to know about other image processing algorithms to pick out and blend individual pixels so that you can assemble the data in a smaller file, again, knowing the exact format of the image file you want write.

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                             2006, 2007, 2008
                        But no longer in 2009...

                        1 Reply Last reply
                        0
                        • G gilvani

                          sorry I was wrong the image is 2.68 gigabytes not 2 megabytes. Can anyone help me?

                          D Offline
                          D Offline
                          DaveyM69
                          wrote on last edited by
                          #12

                          The only thing I can think of is to get a handle to the file without actually loading the file into memory (OpenFile [^] may do this - if not, there may be other functions that will). Once you have that, you can read the data in the file in sections and do what you wish with them, carefully disposing of each section from memory as you go. You'll need to understand the image format so you can interpret the headers and the image data itself. I have no idea with regards to the implementation of this - just an idea that may work.

                          Dave
                          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
                          Why are you using VB6? Do you hate yourself? (Christian Graus)

                          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