![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Bitmap bmpSource = new Bitmap(@"c:\1.bmp"); bmpSource.Clone(); Graphics gSource = Graphics.FromImage(bmpSource); Bitmap bmpDest = new Bitmap(680, 400); // double the size Graphics gDest = Graphics.FromImage(bmpDest); IntPtr dcSource = gSource.GetHdc(); IntPtr dcDest = gDest.GetHdc(); GDI32_DLL.StretchBlt(dcDest, 0, 0, bmpDest.Width, bmpDest.Height, dcSource, 0, 0, bmpSource.Width, bmpSource.Height, GDI32_DLL.TernaryRasterOperations.SRCCOPY); gSource.ReleaseHdc(dcSource); gDest.ReleaseHdc(dcDest); bmpDest.Save(@"c:\6.bmp", ImageFormat.Bmp); MessageBox.Show("Finished Saving Image"); |
#3
| |||
| |||
|
|
"etjon" <etjon (AT) discussions (DOT) microsoft.com> wrote in message news:AC73DE43-273A-4EA1-97B1-B9D3324413AB (AT) microsoft (DOT) com... Bitmap bmpSource = new Bitmap(@"c:\1.bmp"); bmpSource.Clone(); Graphics gSource = Graphics.FromImage(bmpSource); Bitmap bmpDest = new Bitmap(680, 400); // double the size Graphics gDest = Graphics.FromImage(bmpDest); IntPtr dcSource = gSource.GetHdc(); IntPtr dcDest = gDest.GetHdc(); GDI32_DLL.StretchBlt(dcDest, 0, 0, bmpDest.Width, bmpDest.Height, dcSource, 0, 0, bmpSource.Width, bmpSource.Height, GDI32_DLL.TernaryRasterOperations.SRCCOPY); gSource.ReleaseHdc(dcSource); gDest.ReleaseHdc(dcDest); bmpDest.Save(@"c:\6.bmp", ImageFormat.Bmp); MessageBox.Show("Finished Saving Image"); I don't know, but if all you're trying to do is resize 1.bmp, why not: using (Bitmap source = Bitmap.FromFile(@"c:\1.bmp")) using (Bitmap resized = new Bitmap(source, 640, 400)) { resized.Save(@"c:\6.bmp", ImageFormat.Bmp); } And for reference, the second line of your code: bmpSource.Clone(); does absolutely nothing. Cloning returns a NEW object; it does not modify an existing object. . |
#4
| |||
| |||
|
|
Thank your Reply, The second line bmpSource.Clone() , It's test code ,sorry , I want to resize it and use socket send this picture or show form, if i write to file and load file from I/O , It's to slow,but i code is right , why not save it is black color ,because i see my picture is black color in form . So i write bmpDest.Save(@"c:\6.bmp", ImageFormat.Bmp),is my test code Ps: My English is to bad... "Jeff Johnson" wrote: "etjon"<etjon (AT) discussions (DOT) microsoft.com> wrote in message news:AC73DE43-273A-4EA1-97B1-B9D3324413AB (AT) microsoft (DOT) com... Bitmap bmpSource = new Bitmap(@"c:\1.bmp"); bmpSource.Clone(); Graphics gSource = Graphics.FromImage(bmpSource); Bitmap bmpDest = new Bitmap(680, 400); // double the size Graphics gDest = Graphics.FromImage(bmpDest); IntPtr dcSource = gSource.GetHdc(); IntPtr dcDest = gDest.GetHdc(); GDI32_DLL.StretchBlt(dcDest, 0, 0, bmpDest.Width, bmpDest.Height, dcSource, 0, 0, bmpSource.Width, bmpSource.Height, GDI32_DLL.TernaryRasterOperations.SRCCOPY); gSource.ReleaseHdc(dcSource); gDest.ReleaseHdc(dcDest); bmpDest.Save(@"c:\6.bmp", ImageFormat.Bmp); MessageBox.Show("Finished Saving Image"); I don't know, but if all you're trying to do is resize 1.bmp, why not: using (Bitmap source = Bitmap.FromFile(@"c:\1.bmp")) using (Bitmap resized = new Bitmap(source, 640, 400)) { resized.Save(@"c:\6.bmp", ImageFormat.Bmp); } And for reference, the second line of your code: bmpSource.Clone(); does absolutely nothing. Cloning returns a NEW object; it does not modify an existing object. . |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |