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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GDI+ question

GDI+ question

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestionc++winformslearning
4 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.
  • Z Offline
    Z Offline
    ZejulioZ
    wrote on last edited by
    #1

    Hi I'm using GDI+ for a C++ application which is a great library. But this library sooo powerfull is not able to do a simple thing I need to do :( I have a picture 1 x 10 px that I want to stretch to a very flat 100 x 10 px. As result I have a wonderful alpha gradient which is not what I want. Of course I tried to change the interpolation mode to InterpolationModeNearestNeighbor which give me a better result but still not perfect since and - I don't why - the area painted is not completly filled. There is the very simple code : // Load in some initialisation function // a 1 x 100 picture sized m_pBitmap1 = Bitmap::FromFile( csFilename.AllocSysString() ); // Then in onpaint method CPaintDC dc(this); Graphics graphics(dc.m_hDC); graphics.SetInterpolationMode( InterpolationModeNearestNeighbor ); graphics.DrawImage(m_pBitmap1, 0, 0, 100, m_pBitmap1->GetHeight()); Can somebody provide me some explainations or even better... a solution ? :) Thanks

    PJ ArendsP 1 Reply Last reply
    0
    • Z ZejulioZ

      Hi I'm using GDI+ for a C++ application which is a great library. But this library sooo powerfull is not able to do a simple thing I need to do :( I have a picture 1 x 10 px that I want to stretch to a very flat 100 x 10 px. As result I have a wonderful alpha gradient which is not what I want. Of course I tried to change the interpolation mode to InterpolationModeNearestNeighbor which give me a better result but still not perfect since and - I don't why - the area painted is not completly filled. There is the very simple code : // Load in some initialisation function // a 1 x 100 picture sized m_pBitmap1 = Bitmap::FromFile( csFilename.AllocSysString() ); // Then in onpaint method CPaintDC dc(this); Graphics graphics(dc.m_hDC); graphics.SetInterpolationMode( InterpolationModeNearestNeighbor ); graphics.DrawImage(m_pBitmap1, 0, 0, 100, m_pBitmap1->GetHeight()); Can somebody provide me some explainations or even better... a solution ? :) Thanks

      PJ ArendsP Offline
      PJ ArendsP Offline
      PJ Arends
      wrote on last edited by
      #2

      Maybe I am missing something, but why not just use the GDI function StretchBlt. It does not do any of the funky gradient stuff you don't want. Use Graphics::GetHDC to get the HDC handle, and then call Graphics::ReleaseHDC when you are done. It is a very simple way to mix GDI and GDI+ in the same drawing routine.


      "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!

      Within you lies the power for good; Use it!

      C 1 Reply Last reply
      0
      • PJ ArendsP PJ Arends

        Maybe I am missing something, but why not just use the GDI function StretchBlt. It does not do any of the funky gradient stuff you don't want. Use Graphics::GetHDC to get the HDC handle, and then call Graphics::ReleaseHDC when you are done. It is a very simple way to mix GDI and GDI+ in the same drawing routine.


        "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!

        C Offline
        C Offline
        Chris Richardson
        wrote on last edited by
        #3

        Actually, if the stretch blt mode is HALFTONE (anti-aliasing), the image will indeed be alpha blended. Very annoying when you don't want it turning your image into a gradient, but do want a bit of smoothing on the edges. Take a look at SetStretchBltMode if you're curious. Chris Richardson

        Z 1 Reply Last reply
        0
        • C Chris Richardson

          Actually, if the stretch blt mode is HALFTONE (anti-aliasing), the image will indeed be alpha blended. Very annoying when you don't want it turning your image into a gradient, but do want a bit of smoothing on the edges. Take a look at SetStretchBltMode if you're curious. Chris Richardson

          Z Offline
          Z Offline
          ZejulioZ
          wrote on last edited by
          #4

          I haven't tought to mix GDI and GDI+, that's definitely a good idea.. Thank you for the explanations about the anti-aliasing processing. thanks, thanks, thanks :)

          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