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. Graphics.DrawImageUnscaled blurry

Graphics.DrawImageUnscaled blurry

Scheduled Pinned Locked Moved C#
graphicscomquestion
3 Posts 2 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.
  • H Offline
    H Offline
    Huisheng Chen
    wrote on last edited by
    #1

    I want to do a tile by myself, I can see that the result image is very blurry, and the positions of each piece are not correct(overlapped partly), why? Bitmap bitmap = new Bitmap(2000, 2000, PixelFormat.Format32bppArgb); using (Graphics graphic = Graphics.FromImage(bitmap)) { Bitmap image = (Bitmap)Bitmap.FromFile(@"background.bmp"); for (int j = 0; j < 15; j++) { graphic.DrawImageUnscaled(image, (j % 4) * image.Width, (j / 4) * image.Height, image.Width, image.Height); } } bitmap.Save(@"a.png", ImageFormat.Png);

    Regards, unruledboy_at_gmail_dot_com http://www.xnlab.com

    C 1 Reply Last reply
    0
    • H Huisheng Chen

      I want to do a tile by myself, I can see that the result image is very blurry, and the positions of each piece are not correct(overlapped partly), why? Bitmap bitmap = new Bitmap(2000, 2000, PixelFormat.Format32bppArgb); using (Graphics graphic = Graphics.FromImage(bitmap)) { Bitmap image = (Bitmap)Bitmap.FromFile(@"background.bmp"); for (int j = 0; j < 15; j++) { graphic.DrawImageUnscaled(image, (j % 4) * image.Width, (j / 4) * image.Height, image.Width, image.Height); } } bitmap.Save(@"a.png", ImageFormat.Png);

      Regards, unruledboy_at_gmail_dot_com http://www.xnlab.com

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

      The images overlap because your code causes them to. To tile properly, just do j* width and j * height. You can also create a texturebrush which uses the bitmap and tiles, and then just fill the rectangle with that brush

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      H 1 Reply Last reply
      0
      • C Christian Graus

        The images overlap because your code causes them to. To tile properly, just do j* width and j * height. You can also create a texturebrush which uses the bitmap and tiles, and then just fill the rectangle with that brush

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        H Offline
        H Offline
        Huisheng Chen
        wrote on last edited by
        #3

        hi, if I only do j*width and j*height, won't it only be tiling from top left to bottom right(diagonally)? and, it seems that the blurry problem only goes with some bmp files, strange :doh: by the way, I actually want to title all the pictures(not only one) in one picture, something like mosaic, so, texture brush maybe not suitable.

        Regards, unruledboy_at_gmail_dot_com http://www.xnlab.com

        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