PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
How do you resize an image in managed C++ .net using GDI or GDI?
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
How do you resize an image in managed C++ .net using GDI or GDI?
![]() |
How do you resize an image in managed C++ .net using GDI or GDI? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hello.
I'm trying to create a simple program that amongst other things creates a thumbnail of an image (Bitmap) to a set size determined by the user in pixels? The problem is: All of the examples I have seen so far are in c#. Can anyone please provide reference to a c++ managed version. Thanks. John -- www.integrated-dev-sol.co.uk Remove 123 from email address to reply. Anti spam and virus measure. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
"John Swan" <j.a.swan123@ntlworld.com> schrieb:
> I'm trying to create a simple program that amongst other things creates a > thumbnail of an image (Bitmap) to a set size determined by the user in > pixels? > The problem is: All of the examples I have seen so far are in c#. > Can anyone please provide reference to a c++ managed version. C++/CLI sample (requires a reference to "System.Drawing.dll"): \\\ using namespace System; using namespace System: rawing;using namespace System: rawing: rawing2D;using namespace System: rawing::Imaging;int main(array<System::String ^> ^args) { Bitmap ^bmp1 = gcnew Bitmap(L"C:\\WINDOWS\\Angler.bmp"); Bitmap ^bmp2 = gcnew Bitmap( (int)(bmp1->Width * 0.1), (int)(bmp1->Height * 0.1), PixelFormat::Format24bppRgb ); Graphics ^g = Graphics::FromImage(bmp2); g->InterpolationMode = InterpolationMode::HighQualityBicubic; g->DrawImage(bmp1, 0, 0, bmp2->Width, bmp2->Height); bmp2->Save(L"C:\\Test.bmp"); return 0; } /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Thanks for the speedy reply.
I dont actually wish to draw the image. I would like this too be a batch process and it would therefore be considerably quicker in no drawing is done. Any help would be appreciated. "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:eZnuvc0$FHA.316@TK2MSFTNGP10.phx.gbl... > "John Swan" <j.a.swan123@ntlworld.com> schrieb: > > I'm trying to create a simple program that amongst other things creates a > > thumbnail of an image (Bitmap) to a set size determined by the user in > > pixels? > > The problem is: All of the examples I have seen so far are in c#. > > Can anyone please provide reference to a c++ managed version. > > C++/CLI sample (requires a reference to "System.Drawing.dll"): > > \\\ > using namespace System; > using namespace System: rawing;> using namespace System: rawing: rawing2D;> using namespace System: rawing::Imaging;> > int main(array<System::String ^> ^args) > { > Bitmap ^bmp1 = gcnew Bitmap(L"C:\\WINDOWS\\Angler.bmp"); > Bitmap ^bmp2 = gcnew Bitmap( > (int)(bmp1->Width * 0.1), > (int)(bmp1->Height * 0.1), > PixelFormat::Format24bppRgb > ); > Graphics ^g = Graphics::FromImage(bmp2); > g->InterpolationMode = InterpolationMode::HighQualityBicubic; > g->DrawImage(bmp1, 0, 0, bmp2->Width, bmp2->Height); > bmp2->Save(L"C:\\Test.bmp"); > return 0; > } > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> |
|
|
|
#4 |
|
Guest
Posts: n/a
|
"John Swan" <j.a.swan123@ntlworld.com> schrieb:
> I dont actually wish to draw the image. > I would like this too be a batch process and it would therefore be > considerably quicker in no drawing is done. That's exactly what the sample is doing. The code can be used in a console application. 'DrawImage' is used to draw the resized version of the image onto another bitmap which will be persisted by calling its 'Save' method later on. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Oh. Fair enough.
Thanks. You learn something new everyday. Cheers John "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:eMxh372$FHA.2696@TK2MSFTNGP09.phx.gbl... > "John Swan" <j.a.swan123@ntlworld.com> schrieb: > > I dont actually wish to draw the image. > > I would like this too be a batch process and it would therefore be > > considerably quicker in no drawing is done. > > That's exactly what the sample is doing. The code can be used in a console > application. 'DrawImage' is used to draw the resized version of the image > onto another bitmap which will be persisted by calling its 'Save' method > later on. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

rawing;
