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 / C++ / MFC
  4. Conforming a bitmap image to a particular resolution without resizing artefacts, and storing it as a PNG image in a database

Conforming a bitmap image to a particular resolution without resizing artefacts, and storing it as a PNG image in a database

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasegraphicsadobehelp
6 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.
  • S Offline
    S Offline
    Sternocera
    wrote on last edited by
    #1

    Hi guys, I need to do the following in an application I'm developing using C++ and MFC: 1. Open an image of any of the major image formats (say Windows bitmap, Jpeg and PNG). 2. Conform it to a certain resolution. I have a strong preference for doing so without creating any resizing artefacts. I would like the result to be similar to the result you get by resizing an image in Photoshop, rather than the result you get when internet explorer renders and image at a resolution different to that of the image itself (that creates unsettling artefacts). 3. Convert to PNG, and then get a char pointer to a buffer containing the PNG file, so I can serialise the image as a blob in a database for later retrieval. 4. Retrieve the image from the database, and re-create the PNG image to be displayed in my MFC application. How might this be best achieved? I'm not necessarily looking for precise instructions - guidelines may be enough. I have a preference for using lightweight third-party libraries distributed under liberal open source licenses (i.e. not a GPL library). If boost.GIL (generic image library) can help, I'd certain be receptive to that, as I already use boost a lot. That said, given my relatively simple needs even that may be overkill, Regards, Sternocera

    S 1 Reply Last reply
    0
    • S Sternocera

      Hi guys, I need to do the following in an application I'm developing using C++ and MFC: 1. Open an image of any of the major image formats (say Windows bitmap, Jpeg and PNG). 2. Conform it to a certain resolution. I have a strong preference for doing so without creating any resizing artefacts. I would like the result to be similar to the result you get by resizing an image in Photoshop, rather than the result you get when internet explorer renders and image at a resolution different to that of the image itself (that creates unsettling artefacts). 3. Convert to PNG, and then get a char pointer to a buffer containing the PNG file, so I can serialise the image as a blob in a database for later retrieval. 4. Retrieve the image from the database, and re-create the PNG image to be displayed in my MFC application. How might this be best achieved? I'm not necessarily looking for precise instructions - guidelines may be enough. I have a preference for using lightweight third-party libraries distributed under liberal open source licenses (i.e. not a GPL library). If boost.GIL (generic image library) can help, I'd certain be receptive to that, as I already use boost a lot. That said, given my relatively simple needs even that may be overkill, Regards, Sternocera

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Sternocera wrote:

      1. Open an image of any of the major image formats (say Windows bitmap, Jpeg and PNG).

      CImage[^]

      Sternocera wrote:

      2. Conform it to a certain resolution. I have a strong preference for doing so without creating any resizing artefacts. I would like the result to be similar to the result you get by resizing an image in Photoshop, rather than the result you get when internet explorer renders and image at a resolution different to that of the image itself (that creates unsettling artefacts).

      Bicubic Interpolation[^]

      Sternocera wrote:

      3. Convert to PNG, and then get a char pointer to a buffer containing the PNG file, so I can serialise the image as a blob in a database for later retrieval.

      Again, CImage. Use the Save[^] method to save to an IStream created on an HGLOBAL[^], i.e. an IStream that writes to memory. Use a null HGLOBAL to start with, then use GetHGlobalFromStream[^] to get the HGLOBAL that the stream eventually ended up allocating. Then use GlobalSize[^] to get the amount of memory used by the stream and GlobalLock[^] to access the memory.

      S 2 Replies Last reply
      0
      • S Stuart Dootson

        Sternocera wrote:

        1. Open an image of any of the major image formats (say Windows bitmap, Jpeg and PNG).

        CImage[^]

        Sternocera wrote:

        2. Conform it to a certain resolution. I have a strong preference for doing so without creating any resizing artefacts. I would like the result to be similar to the result you get by resizing an image in Photoshop, rather than the result you get when internet explorer renders and image at a resolution different to that of the image itself (that creates unsettling artefacts).

        Bicubic Interpolation[^]

        Sternocera wrote:

        3. Convert to PNG, and then get a char pointer to a buffer containing the PNG file, so I can serialise the image as a blob in a database for later retrieval.

        Again, CImage. Use the Save[^] method to save to an IStream created on an HGLOBAL[^], i.e. an IStream that writes to memory. Use a null HGLOBAL to start with, then use GetHGlobalFromStream[^] to get the HGLOBAL that the stream eventually ended up allocating. Then use GlobalSize[^] to get the amount of memory used by the stream and GlobalLock[^] to access the memory.

        S Offline
        S Offline
        Sternocera
        wrote on last edited by
        #3

        Stuart, Good answer, great tagline, Regards, Sternocera

        1 Reply Last reply
        0
        • S Stuart Dootson

          Sternocera wrote:

          1. Open an image of any of the major image formats (say Windows bitmap, Jpeg and PNG).

          CImage[^]

          Sternocera wrote:

          2. Conform it to a certain resolution. I have a strong preference for doing so without creating any resizing artefacts. I would like the result to be similar to the result you get by resizing an image in Photoshop, rather than the result you get when internet explorer renders and image at a resolution different to that of the image itself (that creates unsettling artefacts).

          Bicubic Interpolation[^]

          Sternocera wrote:

          3. Convert to PNG, and then get a char pointer to a buffer containing the PNG file, so I can serialise the image as a blob in a database for later retrieval.

          Again, CImage. Use the Save[^] method to save to an IStream created on an HGLOBAL[^], i.e. an IStream that writes to memory. Use a null HGLOBAL to start with, then use GetHGlobalFromStream[^] to get the HGLOBAL that the stream eventually ended up allocating. Then use GlobalSize[^] to get the amount of memory used by the stream and GlobalLock[^] to access the memory.

          S Offline
          S Offline
          Sternocera
          wrote on last edited by
          #4

          Stuart Dootson wrote:

          cubic Interpolation[^]

          Stuart, Can you suggest a practical way to use Bicubic interpolation to resize my CImage? Obviously it's preferable to use some proven third party library rather than re-inventing the wheel. Again, *any* guidance you can offer is helpful, I'm not necessarily looking for step-by-step instructions. Google has not been helpful here, Regards, Sternocera

          S CPalliniC 2 Replies Last reply
          0
          • S Sternocera

            Stuart Dootson wrote:

            cubic Interpolation[^]

            Stuart, Can you suggest a practical way to use Bicubic interpolation to resize my CImage? Obviously it's preferable to use some proven third party library rather than re-inventing the wheel. Again, *any* guidance you can offer is helpful, I'm not necessarily looking for step-by-step instructions. Google has not been helpful here, Regards, Sternocera

            S Offline
            S Offline
            Stuart Dootson
            wrote on last edited by
            #5

            CxImage[^] has plenty of interpolation algorithms. After some research, Lanczos resampling may be better than bicubic - CxImage does both. [edit]FreeImage[^] is another image processing library with interpolation. The documentaton includes a section on choosing the right interpolation algorithm, which could be handy[/edit]

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            1 Reply Last reply
            0
            • S Sternocera

              Stuart Dootson wrote:

              cubic Interpolation[^]

              Stuart, Can you suggest a practical way to use Bicubic interpolation to resize my CImage? Obviously it's preferable to use some proven third party library rather than re-inventing the wheel. Again, *any* guidance you can offer is helpful, I'm not necessarily looking for step-by-step instructions. Google has not been helpful here, Regards, Sternocera

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              You might try my DLL [^]. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              In testa che avete, signor di Ceprano?

              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