There is no need to ask the same question twice. Christian Schwarz gave
you the idea yesterday. Here you are the complete list:
Bitmap scaledImg = ScaleBitmap(sourceBitmap, 0.5f, 0.5f);
....
public Bitmap ScaleBitmap(Bitmap src, float xscale, float yscale)
{
Bitmap res = new Bitmap((int)(src.Width*xscale),
(int)(src.Height*yscale));
using (Graphics g = Graphics.FromImage(res))
{
g.DrawImage(src, new Rectangle(0, 0, res.Width, res.Height), 0, 0,
src.Width, src.Height, GraphicsUnit.Pixel, new
System.Drawing.Imaging.ImageAttributes());
}
return res;
}
--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com
Naveen said:
Sir the function you have sent me is not working, this part in the function
is not working as it shows error bitmap does not take three arguments,I have
tried it before also.for this function i need alternative
**********************************************************
Bitmap scaledImg = new
Bitmap(img,(int)(img.Width*scale),(int)(img.Height*scale));
************************************************************
Regards
Naveen
scale = value;
Bitmap img = ....; your original bitmap here
Bitmap scaledImg = new
Bitmap(img,(int)(img.Width*scale),(int)(img.Height*scale));
:
The function I sent you will scale the bitmap for you, it is the only way to
do it the compact framework (without writing your own scaling code that is).
scale = value;
Bitmap img = ....; your original bitmap here
Bitmap scaledImg = new
Bitmap(img,(int)(img.Width*scale),(int)(img.Height*scale));
Graphics g = Graphics.FrimImage(scaledImg);
g.DrawImage(img, new Rectangle(0,0,scaledImg.Width,scaledImg.Height), new
Rectangle(0,0,img.Width,img.Height),
GraphicsUnit.Pixel)
convertToGrayScale();
No this is not the thing i want, i feel your are not able to get what i am
really asking for.
i have a function were image is scaled in .net frameworkthat function is
written as this
**********************************************************
were scale is 1.0;
scale = value;
Bitmap scaledImg = new
Bitmap(img,(int)(img.Width*scale),(int)(img.Height*scale));
convertToGrayScale();
**********************************************************
Now i want to write this function in comapct frame work . as from here the
value of width and height goes to convertto grayscale function which is
like
this
************************************************************
protected void convertToGrayScale()
{
Color col;
int gray;
for (int l = 0; l<scaledImg.Width; l++)
for (int c = 0; c<scaledImg.Height; c++)
{
col = scaledImg.GetPixel(l,c);
gray = (int)(0.32f * col.R + 0.5f * col.G + 0.18f* col.B);
scaledImg.SetPixel(l,c,Color.FromArgb(gray, gray, gray));
}
}
***************************************************************
if i am passing like this in compactframework
**********************************************************
Bitmap scaledImg = new Bitmap(img);
*********************************************************
the values passing to convert to gray function are wrong.
so i hardly get correct results.
So please teelme alternative for this a.
Regards
Naveen
:
Is this what you want?
Dim b As New Bitmap(x, y)
Dim g As Graphics = Graphics.FromImage(b)
g.DrawImage(AnotherBitmap, destinationRectangle, SourceRectangle,
GraphicsUnit.Pixel)
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