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?

Reply

How do you resize an image in managed C++ .net using GDI or GDI?

 
Thread Tools Rate Thread
Old 12-12-2005, 05:39 PM   #1
John Swan
Guest
 
Posts: n/a
Default How do you resize an image in managed C++ .net using GDI or GDI?


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.


  Reply With Quote
Old 12-12-2005, 06:09 PM   #2
Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
Default Re: How do you resize an image in managed C++ .net using GDI or GDI?

"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/>
  Reply With Quote
Old 12-12-2005, 09:31 PM   #3
John Swan
Guest
 
Posts: n/a
Default Re: How do you resize an image in managed C++ .net using GDI or GDI?

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/>



  Reply With Quote
Old 12-12-2005, 10:54 PM   #4
Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
Default Re: How do you resize an image in managed C++ .net using GDI or GDI?

"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/>

  Reply With Quote
Old 12-12-2005, 11:08 PM   #5
John Swan
Guest
 
Posts: n/a
Default Re: How do you resize an image in managed C++ .net using GDI or GDI?

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/>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off