PC Review


Reply
Thread Tools Rate Thread

how to assign a scaled bitmap into another bitmap(

 
 
=?Utf-8?B?TmF2ZWVuIGtvdWw=?=
Guest
Posts: n/a
 
      4th Oct 2005
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
 
Reply With Quote
 
 
 
 
Joseph Byrns
Guest
Posts: n/a
 
      4th Oct 2005
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)



"Naveen koul" <(E-Mail Removed)> wrote in message
news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?TmF2ZWVuIGtvdWw=?=
Guest
Posts: n/a
 
      4th Oct 2005
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

"Joseph Byrns" wrote:

> 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)
>
>
>
> "Naveen koul" <(E-Mail Removed)> wrote in message
> news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
Joseph Byrns
Guest
Posts: n/a
 
      4th Oct 2005
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();



"Naveen koul" <(E-Mail Removed)> wrote in message
news:B6AD9ACC-A511-4E34-8BC2-(E-Mail Removed)...
> 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
>
> "Joseph Byrns" wrote:
>
>> 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)
>>
>>
>>
>> "Naveen koul" <(E-Mail Removed)> wrote in message
>> news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
>> > 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

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?TmF2ZWVuIGtvdWw=?=
Guest
Posts: n/a
 
      5th Oct 2005

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));
"Joseph Byrns" wrote:

> 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();
>
>
>
> "Naveen koul" <(E-Mail Removed)> wrote in message
> news:B6AD9ACC-A511-4E34-8BC2-(E-Mail Removed)...
> > 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
> >
> > "Joseph Byrns" wrote:
> >
> >> 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)
> >>
> >>
> >>
> >> "Naveen koul" <(E-Mail Removed)> wrote in message
> >> news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
> >> > 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
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Sergey Bogdanov
Guest
Posts: n/a
 
      5th Oct 2005
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 koul wrote:
> 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));
> "Joseph Byrns" wrote:
>
>
>>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();
>>
>>
>>
>>"Naveen koul" <(E-Mail Removed)> wrote in message
>>news:B6AD9ACC-A511-4E34-8BC2-(E-Mail Removed)...
>>
>>>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
>>>
>>>"Joseph Byrns" wrote:
>>>
>>>
>>>>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)
>>>>
>>>>
>>>>
>>>>"Naveen koul" <(E-Mail Removed)> wrote in message
>>>>news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
>>>>
>>>>>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
>>>>
>>>>
>>>>

>>
>>

 
Reply With Quote
 
=?Utf-8?B?TmF2ZWVuIGtvdWw=?=
Guest
Posts: n/a
 
      5th Oct 2005

Sir,

Yes there was no question of posting the post twice , but the question in
both post is different . in first post i forgot to mention that i dont want
to draw image . I want to copy the bitmap ,
Again i am repeating the question. i dont want to draw the image i want to
copy the bitmap.

i hope my query will be bit clear now.

Regards

Naveen
"Sergey Bogdanov" wrote

> 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 koul wrote:
> > 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));
> > "Joseph Byrns" wrote:
> >
> >
> >>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();
> >>
> >>
> >>
> >>"Naveen koul" <(E-Mail Removed)> wrote in message
> >>news:B6AD9ACC-A511-4E34-8BC2-(E-Mail Removed)...
> >>
> >>>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
> >>>
> >>>"Joseph Byrns" wrote:
> >>>
> >>>
> >>>>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)
> >>>>
> >>>>
> >>>>
> >>>>"Naveen koul" <(E-Mail Removed)> wrote in message
> >>>>news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
> >>>>
> >>>>>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
> >>>>
> >>>>
> >>>>
> >>
> >>

>

 
Reply With Quote
 
Sergey Bogdanov
Guest
Posts: n/a
 
      5th Oct 2005
The code snippet from the previous post does exactly what you are
looking for. Just try to invoke this method - it will return a copy of
Bitmap.

I believe, I understand where you stick. The Graphics.FromImage returns
something like of "Device Context" for a given Bitmap. This context is
used for copying one Bitmap to another by using the Draw method. It
doesn't display a Bitmap, it just makes an copy.

Again, just test it.

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


Naveen koul wrote:
> Sir,
>
> Yes there was no question of posting the post twice , but the question in
> both post is different . in first post i forgot to mention that i dont want
> to draw image . I want to copy the bitmap ,
> Again i am repeating the question. i dont want to draw the image i want to
> copy the bitmap.
>
> i hope my query will be bit clear now.
>
> Regards
>
> Naveen
> "Sergey Bogdanov" wrote
>
>
>>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 koul wrote:
>>
>>>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));
>>>"Joseph Byrns" wrote:
>>>
>>>
>>>
>>>>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();
>>>>
>>>>
>>>>
>>>>"Naveen koul" <(E-Mail Removed)> wrote in message
>>>>news:B6AD9ACC-A511-4E34-8BC2-(E-Mail Removed)...
>>>>
>>>>
>>>>>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
>>>>>
>>>>>"Joseph Byrns" wrote:
>>>>>
>>>>>
>>>>>
>>>>>>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)
>>>>>>
>>>>>>
>>>>>>
>>>>>>"Naveen koul" <(E-Mail Removed)> wrote in message
>>>>>>news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
>>>>>>
>>>>>>
>>>>>>>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
>>>>>>
>>>>>>
>>>>>>
>>>>

 
Reply With Quote
 
Joseph Byrns
Guest
Posts: n/a
 
      5th Oct 2005
Yes sorry, the line:

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

in the example I sent should be:

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


The scaling is done below that line in the g.DrawImage(...)


"Naveen koul" <(E-Mail Removed)> wrote in message
news:946A2BE5-08FE-4EAD-9BD5-(E-Mail Removed)...
>
> 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));
> "Joseph Byrns" wrote:
>
>> 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();
>>
>>
>>
>> "Naveen koul" <(E-Mail Removed)> wrote in message
>> news:B6AD9ACC-A511-4E34-8BC2-(E-Mail Removed)...
>> > 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
>> >
>> > "Joseph Byrns" wrote:
>> >
>> >> 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)
>> >>
>> >>
>> >>
>> >> "Naveen koul" <(E-Mail Removed)> wrote in message
>> >> news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
>> >> > 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
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?TmF2ZWVuIGtvdWw=?=
Guest
Posts: n/a
 
      5th Oct 2005
Sir,

I tried the same thing , but when the cursor goes to the convert to grey
scale function . it gives error moves to catch.were if i see img valur it
shows up unfedined.

i am giving the fragments of code
************************************************************
First it loads the image from here this function
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
try
{
img = new PMImage("\\Naveen.jpg");

}
catch {}
if (img != null)
{
matchs = n.search(img);

}
}
**********************************************************
After this function it goes to to the scaling function

public float Scale
{

set
{
scale = 1.0;
Bitmap scaledImg = ScaleBitmap(img, 0.5f, 0.5f);
convertToGrayScale();
}
}
**********************************************************
From this function it enters the ScaleBitmap function which was provided by
you

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;
}
**********************************************************
from return res function goes back to Bitmap scaledImg, from there when the
function goes to convertToGrayScale(), from there the dubigguer moves to
catch m and when it checks the if condition it founds the img value
=undefined, so come out it and just hang up.


I hope i am more clear this time

Regards

naveen


"Joseph Byrns" wrote:

> Yes sorry, the line:
>
> Bitmap scaledImg = new
> Bitmap(img,(int)(img.Width*scale),(int)(img.Height*scale));
>
> in the example I sent should be:
>
> Bitmap scaledImg = new
> Bitmap((int)(img.Width*scale),(int)(img.Height*scale));
>
>
> The scaling is done below that line in the g.DrawImage(...)
>
>
> "Naveen koul" <(E-Mail Removed)> wrote in message
> news:946A2BE5-08FE-4EAD-9BD5-(E-Mail Removed)...
> >
> > 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));
> > "Joseph Byrns" wrote:
> >
> >> 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();
> >>
> >>
> >>
> >> "Naveen koul" <(E-Mail Removed)> wrote in message
> >> news:B6AD9ACC-A511-4E34-8BC2-(E-Mail Removed)...
> >> > 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
> >> >
> >> > "Joseph Byrns" wrote:
> >> >
> >> >> 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)
> >> >>
> >> >>
> >> >>
> >> >> "Naveen koul" <(E-Mail Removed)> wrote in message
> >> >> news613F3FA-A570-4EFB-9BE6-(E-Mail Removed)...
> >> >> > 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
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'System.Drawing.Bitmap.Bitmap()' Error Fir5tSight Microsoft Dot NET 7 23rd Jun 2006 12:44 PM
copy a portion of a bitmap to another bitmap (via picturebox or other method) ? Mad Scientist Jr Microsoft VB .NET 2 31st Jan 2005 03:26 PM
Extract portion of a bitmap to display, not entire bitmap. Alex Gray Microsoft C# .NET 2 22nd Feb 2004 02:42 PM
Question on how to access bitmap: Public Function getBitmap() As Bitmap Michael Murphy Microsoft VB .NET 2 7th Oct 2003 02:54 PM
extract OLE bitmap from table and save as a bitmap file Brett Rawcliffe Microsoft Access 1 19th Jul 2003 04:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:22 PM.