how to do bitmap scaling in compactframework

G

Guest

hi,

i am facing acertian problem in scaling an image in compactframework.
i have got a certain piece of code written below which i have written for
..net framework and need to convert it for compactframework.
************************************************************
scaledImg = new Bitmap(img,(int)(img.Width*scale),(int)(img.Height*scale));

************************************************************
i tried just could found only this alternative

**********************************************************
scaledImg = new Bitmap(img);//(int)(img.Width*scale),(int)(img.Height*scale));

**********************************************************

But due to this i am getting wrong results .

Can anyone please help in converting the above function in compactframe work.

waiting for reply eagerly.

Regards

Naveen
 
C

Christian Schwarz

scaledImg = new
Bitmap(img);//(int)(img.Width*scale),(int)(img.Height*scale));

Try the following:

Bitmap scaledImg = new Bitmap((int)(img.Width*scale),
(int)(img.Height*scale));

using (Graphics gfx = Graphics.FromImage(scaledImg))
{
gfx.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height), 0, 0,
img.Width, img.Height, GraphicsUnit.Pixel, new Imaging.ImageAttributes());
}

Christian
 
G

Guest

Sir,

what is this new Imaging.ImageAttributes(); as it is giving me error.

regards

Naveen
 
G

Guest

Sir
( new Imaging.ImageAttributes())
it is giving me this sort of error
: "The type or namespace name 'Imaging' could not be found (are you missing
a using directive or an assembly reference?)"
 
G

Guest

Sir,

I want to assign a scaled bitmap into another bit map
how to do it.i have got a.net framework function which is working fime and i
need an alternative for it to make it working for .net compactframework.
************************************************************
scaledImg = new Bitmap(img,(int)(img.Width*scale),(int)(img.Height*scale));

************************************************************

How can this be done.

regards

Naveem
 
C

Christian Schwarz

Sir,

I'm not a Sir :)
what is this new Imaging.ImageAttributes(); as it is giving me error.

ImageAttributes class resides in the "System.Drawing.Imaging" namespace.

Christian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top