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