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. Graphics
  4. GDI+ Scaling all wrong?

GDI+ Scaling all wrong?

Scheduled Pinned Locked Moved Graphics
graphicscsharpwinformsquestion
4 Posts 3 Posters 6 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.
  • C Offline
    C Offline
    Chinners
    wrote on last edited by
    #1

    Hi Group, I have a little app that loads a PNG image (128x128x32), and draws it to another canvas, with scaling. The destination size is 512x512, and, using VB.net, I use the commands (g is a graphics Canvas)

    g.FillRectangle(Brushes.White, New Rectangle(0, 0, 512, 512))
    g.DrawImage(Img, 0, 0, 512, 512)

    However, the image drawn to the canvas is more like 560x560 pixels. Does anyone know why this is happening? The source image is definately 128x128, and is 72dpi... although this shouldnt affect anything... should it? Thanks, Jason

    L C 2 Replies Last reply
    0
    • C Chinners

      Hi Group, I have a little app that loads a PNG image (128x128x32), and draws it to another canvas, with scaling. The destination size is 512x512, and, using VB.net, I use the commands (g is a graphics Canvas)

      g.FillRectangle(Brushes.White, New Rectangle(0, 0, 512, 512))
      g.DrawImage(Img, 0, 0, 512, 512)

      However, the image drawn to the canvas is more like 560x560 pixels. Does anyone know why this is happening? The source image is definately 128x128, and is 72dpi... although this shouldnt affect anything... should it? Thanks, Jason

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      How about trying DrawImageUnscaled?

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)

      C 1 Reply Last reply
      0
      • L leppie

        How about trying DrawImageUnscaled?

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)

        C Offline
        C Offline
        Chinners
        wrote on last edited by
        #3

        Hi Leppie, That wont work - I need the image scaling. Looking around a bit, I think that GDI+ is being too clever. I noticed that the PNGs that didnt work well had a different Dots-per-inch setting to ones that did. So, I suppose I aught to amend my question to say how do I get GDI+ to ignore these values, and simply do what I asked of it - scale a bitmap to fit a rectangle :mad::confused: thanks Jason

        1 Reply Last reply
        0
        • C Chinners

          Hi Group, I have a little app that loads a PNG image (128x128x32), and draws it to another canvas, with scaling. The destination size is 512x512, and, using VB.net, I use the commands (g is a graphics Canvas)

          g.FillRectangle(Brushes.White, New Rectangle(0, 0, 512, 512))
          g.DrawImage(Img, 0, 0, 512, 512)

          However, the image drawn to the canvas is more like 560x560 pixels. Does anyone know why this is happening? The source image is definately 128x128, and is 72dpi... although this shouldnt affect anything... should it? Thanks, Jason

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          I don't htink GDI+ does anything with DPI. You can set DPI in code tho, if you need to try that.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          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