![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, I have the following code... Bitmap bitmap = new Bitmap((int)new_width, (int)new_height, m_src_image.PixelFormat); m_graphics = Graphics.FromImage(bitmap); m_graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality ; m_graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic; m_graphics.DrawImage(m_src_image, 0, 0, bitmap.Width, bitmap.Height); m_dst_image = bitmap; When I resize an image (large to small) I get a distinct edge on the top and left of the image, about 2 pixels wide. This is a distraction, so I have thought about cropping it to drop the edge. I am not sure though how to do it. The way I think is to make the original image 2 pixels larger in both directions, then crop from top + 2 and left + 2. I am only guessing but not sure here, the line with... m_graphics.DrawImage(m_src_image, 0, 0, bitmap.Width, bitmap.Height); if I make the parameters (m_src_image, 2, 2, bitmap.Width + 2, bitmap.Height + 2) would this crop the image, or would it move the canvas? If it doesn't crop, can you suggest an alternative? Best regards, Dave Colliver. http://www.DoncasterFOCUS.com ~~ http://www.FOCUSPortals.com - Local franchises available |
#3
| |||
| |||
|
|
You could define a Rectangle for that portion of the bitmap that you wish to crop and use the Bitmap Clone method to create a cropped bitmap. "David" <david.colliver.NEWS (AT) revilloc (DOT) REMOVETHIS.com> wrote in message news:ud3Cl02wFHA.460 (AT) TK2MSFTNGP15 (DOT) phx.gbl... Hi all, I have the following code... Bitmap bitmap = new Bitmap((int)new_width, (int)new_height, m_src_image.PixelFormat); m_graphics = Graphics.FromImage(bitmap); m_graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality ; m_graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic; m_graphics.DrawImage(m_src_image, 0, 0, bitmap.Width, bitmap.Height); m_dst_image = bitmap; When I resize an image (large to small) I get a distinct edge on the top and left of the image, about 2 pixels wide. This is a distraction, so I have thought about cropping it to drop the edge. I am not sure though how to do it. The way I think is to make the original image 2 pixels larger in both directions, then crop from top + 2 and left + 2. I am only guessing but not sure here, the line with... m_graphics.DrawImage(m_src_image, 0, 0, bitmap.Width, bitmap.Height); if I make the parameters (m_src_image, 2, 2, bitmap.Width + 2, bitmap.Height + 2) would this crop the image, or would it move the canvas? If it doesn't crop, can you suggest an alternative? Best regards, Dave Colliver. http://www.DoncasterFOCUS.com ~~ http://www.FOCUSPortals.com - Local franchises available |
#4
| |||
| |||
|
|
Hi, Thanks. I am not sure how to implement your suggestion, but I expanded on what I thought. I came up with m_graphics.DrawImage(m_src_image, -2, -2, bitmap.Width+2, bitmap.Height+2); This seems to work though I don't know if I am missing something. The image seems the same size as requested, and I have tried the fix on an image with white edges and one with dark edges. I can't see anything missing. Best regards, Dave Colliver. http://www.AshfieldFOCUS.com ~~ http://www.FOCUSPortals.com - Local franchises available "Michael Phillips, Jr." <mphillips53 (AT) nospam (DOT) jun0.c0m> wrote in message news:uyv1h62wFHA.460 (AT) TK2MSFTNGP15 (DOT) phx.gbl... You could define a Rectangle for that portion of the bitmap that you wish to crop and use the Bitmap Clone method to create a cropped bitmap. "David" <david.colliver.NEWS (AT) revilloc (DOT) REMOVETHIS.com> wrote in message news:ud3Cl02wFHA.460 (AT) TK2MSFTNGP15 (DOT) phx.gbl... Hi all, I have the following code... Bitmap bitmap = new Bitmap((int)new_width, (int)new_height, m_src_image.PixelFormat); m_graphics = Graphics.FromImage(bitmap); m_graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality ; m_graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic; m_graphics.DrawImage(m_src_image, 0, 0, bitmap.Width, bitmap.Height); m_dst_image = bitmap; When I resize an image (large to small) I get a distinct edge on the top and left of the image, about 2 pixels wide. This is a distraction, so I have thought about cropping it to drop the edge. I am not sure though how to do it. The way I think is to make the original image 2 pixels larger in both directions, then crop from top + 2 and left + 2. I am only guessing but not sure here, the line with... m_graphics.DrawImage(m_src_image, 0, 0, bitmap.Width, bitmap.Height); if I make the parameters (m_src_image, 2, 2, bitmap.Width + 2, bitmap.Height + 2) would this crop the image, or would it move the canvas? If it doesn't crop, can you suggest an alternative? Best regards, Dave Colliver. http://www.DoncasterFOCUS.com ~~ http://www.FOCUSPortals.com - Local franchises available |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |