Hi,there
i 'm writing an application about bitmap displaying.But i find it
works not very well because of the terrorable performance .

here's my code

/// <summary>
/// Get BMP according to the FrameNumber,then display
/// </summary>
/// <param name="FrameNo"></param>
/// <param name="FandR_Flag">direction</param>
/// <returns></returns>
public Bitmap createImage(int FrameNo, int FandR_Flag)
{
string xustr;
byte[] xutest;
xustr = "CAM";

//find image,cost about 1ms
xutest = ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);

//read byte[] into memostream,cost about 1ms
MemoryStream ms = new MemoryStream(xutest, 0, xutest.Length);

//here cost 423ms to construct an bmp, what happened
here?!!!!!!!!!!!!!!!!!!!!!!!!
Bitmap bmp = new Bitmap(ms);

xutest = null;
ms.Close();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
return bmp;
}

Any suggestion?

Thanks in advance~

Regards,

Freesc

RE: SLOW bitmap from Stream by srhartone

srhartone
Fri Mar 07 15:10:00 CST 2008

Under half a second is not that out of the ordinary loading an image on a
device. How big is the image, on what device, how much RAM?

Calling the garbage collector is costing you, I'd get rid of that code if I
were you.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"Freesc" wrote:

> Hi,there
> i 'm writing an application about bitmap displaying.But i find it
> works not very well because of the terrorable performance .
>
> here's my code
>
> /// <summary>
> /// Get BMP according to the FrameNumber,then display
> /// </summary>
> /// <param name="FrameNo"></param>
> /// <param name="FandR_Flag">direction</param>
> /// <returns></returns>
> public Bitmap createImage(int FrameNo, int FandR_Flag)
> {
> string xustr;
> byte[] xutest;
> xustr = "CAM";
>
> //find image,cost about 1ms
> xutest = ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
>
> //read byte[] into memostream,cost about 1ms
> MemoryStream ms = new MemoryStream(xutest, 0, xutest.Length);
>
> //here cost 423ms to construct an bmp, what happened
> here?!!!!!!!!!!!!!!!!!!!!!!!!
> Bitmap bmp = new Bitmap(ms);
>
> xutest = null;
> ms.Close();
> GC.Collect();
> GC.WaitForPendingFinalizers();
> GC.Collect();
> return bmp;
> }
>
> Any suggestion?
>
> Thanks in advance~
>
> Regards,
>
> Freesc
>

Re: SLOW bitmap from Stream by Freesc

Freesc
Fri Mar 07 21:32:42 CST 2008

On Mar 8, 5:10=A0am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> Under half a second is not that out of the ordinary loading an image on a
> device. How big is the image, on what device, how much RAM?
>
> Calling the garbage collector is costing you, I'd get rid of that code if =
I
> were you.
> --
> Simon Hart
> Visual Developer - Device Application Development MVPhttp://simonrhart.blo=
gspot.com
>
>
>
> "Freesc" wrote:
> > Hi,there
> > i 'm writing an application about bitmap displaying.But i find it
> > works not very well because of the terrorable performance .
>
> > here's my code
>
> > /// <summary>
> > /// Get BMP according to the FrameNumber,then display
> > /// </summary>
> > /// <param name=3D"FrameNo"></param>
> > /// <param name=3D"FandR_Flag">direction</param>
> > /// <returns></returns>
> > public Bitmap createImage(int FrameNo, int FandR_Flag)
> > {
> > string xustr;
> > byte[] xutest;
> > xustr =3D "CAM";
>
> > //find image,cost about 1ms
> > xutest =3D ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
>
> > //read byte[] into memostream,cost about 1ms
> > MemoryStream ms =3D new MemoryStream(xutest, 0, xutest.Length);
>
> > //here cost 423ms to construct an bmp, what happened
> > here?!!!!!!!!!!!!!!!!!!!!!!!!
> > Bitmap bmp =3D new Bitmap(ms);
>
> > xutest =3D null;
> > ms.Close();
> > GC.Collect();
> > GC.WaitForPendingFinalizers();
> > GC.Collect();
> > return bmp;
> > }
>
> > Any suggestion?
>
> > Thanks in advance~
>
> > Regards,
>
> > Freesc- Hide quoted text -
>
> - Show quoted text -

Hi,Simon

Thanks for you reply~
i would remove the GC code.

i think 400ms is unbearable because this is a video solution, it must
be 4 or 5 frames per secend as we expect
and i can not find something like Bitmap.FromStream(new
memorystream(...)) in .NET Compactframe , so i can not prevent
constructing a new bitmap when a new frame comes
Any suggestion about that?I have to reduce the cost , but i can't find
an effective way....
thanks again~

Regards~

Re: SLOW bitmap from Stream by ctacke/>

ctacke/>
Fri Mar 07 23:03:26 CST 2008

You didn't answer any of Simon's question. How big is the image? What
format is it? Color depth? What kind of device? Processor speed? RAM?
etc. etc. etc...


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



"Freesc" <hjd.click@gmail.com> wrote in message
news:06ce049f-ea54-42f1-926d-7f6df31055db@u10g2000prn.googlegroups.com...
On Mar 8, 5:10 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> Under half a second is not that out of the ordinary loading an image on a
> device. How big is the image, on what device, how much RAM?
>
> Calling the garbage collector is costing you, I'd get rid of that code if
> I
> were you.
> --
> Simon Hart
> Visual Developer - Device Application Development
> MVPhttp://simonrhart.blogspot.com
>
>
>
> "Freesc" wrote:
> > Hi,there
> > i 'm writing an application about bitmap displaying.But i find it
> > works not very well because of the terrorable performance .
>
> > here's my code
>
> > /// <summary>
> > /// Get BMP according to the FrameNumber,then display
> > /// </summary>
> > /// <param name="FrameNo"></param>
> > /// <param name="FandR_Flag">direction</param>
> > /// <returns></returns>
> > public Bitmap createImage(int FrameNo, int FandR_Flag)
> > {
> > string xustr;
> > byte[] xutest;
> > xustr = "CAM";
>
> > //find image,cost about 1ms
> > xutest = ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
>
> > //read byte[] into memostream,cost about 1ms
> > MemoryStream ms = new MemoryStream(xutest, 0, xutest.Length);
>
> > //here cost 423ms to construct an bmp, what happened
> > here?!!!!!!!!!!!!!!!!!!!!!!!!
> > Bitmap bmp = new Bitmap(ms);
>
> > xutest = null;
> > ms.Close();
> > GC.Collect();
> > GC.WaitForPendingFinalizers();
> > GC.Collect();
> > return bmp;
> > }
>
> > Any suggestion?
>
> > Thanks in advance~
>
> > Regards,
>
> > Freesc- Hide quoted text -
>
> - Show quoted text -

Hi,Simon

Thanks for you reply~
i would remove the GC code.

i think 400ms is unbearable because this is a video solution, it must
be 4 or 5 frames per secend as we expect
and i can not find something like Bitmap.FromStream(new
memorystream(...)) in .NET Compactframe , so i can not prevent
constructing a new bitmap when a new frame comes
Any suggestion about that?I have to reduce the cost , but i can't find
an effective way....
thanks again~

Regards~



Re: SLOW bitmap from Stream by Freesc

Freesc
Sat Mar 08 05:27:40 CST 2008

On Mar 8, 1:03=A0pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
> You didn't answer any of Simon's question. How big is the image? =A0What
> format is it? =A0Color depth? What kind of device? =A0Processor speed? RAM=
?
> etc. etc. etc...
>
> --
>
> Chris Tacke, eMVP
> Join the Embedded Developer Communityhttp://community.opennetcf.com
>
> "Freesc" <hjd.cl...@gmail.com> wrote in message
>
> news:06ce049f-ea54-42f1-926d-7f6df31055db@u10g2000prn.googlegroups.com...
> On Mar 8, 5:10 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
>
>
>
>
>
> > Under half a second is not that out of the ordinary loading an image on =
a
> > device. How big is the image, on what device, how much RAM?
>
> > Calling the garbage collector is costing you, I'd get rid of that code i=
f
> > I
> > were you.
> > --
> > Simon Hart
> > Visual Developer - Device Application Development
> > MVPhttp://simonrhart.blogspot.com
>
> > "Freesc" wrote:
> > > Hi,there
> > > i 'm writing an application about bitmap displaying.But i find it
> > > works not very well because of the terrorable performance .
>
> > > here's my code
>
> > > /// <summary>
> > > /// Get BMP according to the FrameNumber,then display
> > > /// </summary>
> > > /// <param name=3D"FrameNo"></param>
> > > /// <param name=3D"FandR_Flag">direction</param>
> > > /// <returns></returns>
> > > public Bitmap createImage(int FrameNo, int FandR_Flag)
> > > {
> > > string xustr;
> > > byte[] xutest;
> > > xustr =3D "CAM";
>
> > > //find image,cost about 1ms
> > > xutest =3D ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
>
> > > //read byte[] into memostream,cost about 1ms
> > > MemoryStream ms =3D new MemoryStream(xutest, 0, xutest.Length);
>
> > > //here cost 423ms to construct an bmp, what happened
> > > here?!!!!!!!!!!!!!!!!!!!!!!!!
> > > Bitmap bmp =3D new Bitmap(ms);
>
> > > xutest =3D null;
> > > ms.Close();
> > > GC.Collect();
> > > GC.WaitForPendingFinalizers();
> > > GC.Collect();
> > > return bmp;
> > > }
>
> > > Any suggestion?
>
> > > Thanks in advance~
>
> > > Regards,
>
> > > Freesc- Hide quoted text -
>
> > - Show quoted text -
>
> Hi,Simon
>
> Thanks for you reply~
> i would remove the GC code.
>
> =A0i think 400ms is unbearable because this is a video solution, it must
> be 4 or 5 frames per secend as we expect
> and i can not find something like Bitmap.FromStream(new
> memorystream(...)) in .NET Compactframe , so i can not prevent
> constructing a new bitmap when a new frame comes
> Any suggestion about that?I have to reduce the cost , but i can't find
> an effective way....
> thanks again~
>
> Regards~- Hide quoted text -
>
> - Show quoted text -

Oops~~~

sorry about that ~ :-)

each frame is an Image of 240*180 Bitmap(24bit) , we test our
application in an XScale device of 416Mhz, 128MB ROM,64MB RAM

Thanks Chris~






Re: SLOW bitmap from Stream by srhartone

srhartone
Wed Mar 12 17:51:00 CDT 2008

I forgot to mention you arn't using anything stupid such as directX are you,
I'm assuming GDI.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"Freesc" wrote:

> On Mar 8, 1:03 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
> > You didn't answer any of Simon's question. How big is the image? What
> > format is it? Color depth? What kind of device? Processor speed? RAM?
> > etc. etc. etc...
> >
> > --
> >
> > Chris Tacke, eMVP
> > Join the Embedded Developer Communityhttp://community.opennetcf.com
> >
> > "Freesc" <hjd.cl...@gmail.com> wrote in message
> >
> > news:06ce049f-ea54-42f1-926d-7f6df31055db@u10g2000prn.googlegroups.com...
> > On Mar 8, 5:10 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> >
> >
> >
> >
> >
> > > Under half a second is not that out of the ordinary loading an image on a
> > > device. How big is the image, on what device, how much RAM?
> >
> > > Calling the garbage collector is costing you, I'd get rid of that code if
> > > I
> > > were you.
> > > --
> > > Simon Hart
> > > Visual Developer - Device Application Development
> > > MVPhttp://simonrhart.blogspot.com
> >
> > > "Freesc" wrote:
> > > > Hi,there
> > > > i 'm writing an application about bitmap displaying.But i find it
> > > > works not very well because of the terrorable performance .
> >
> > > > here's my code
> >
> > > > /// <summary>
> > > > /// Get BMP according to the FrameNumber,then display
> > > > /// </summary>
> > > > /// <param name="FrameNo"></param>
> > > > /// <param name="FandR_Flag">direction</param>
> > > > /// <returns></returns>
> > > > public Bitmap createImage(int FrameNo, int FandR_Flag)
> > > > {
> > > > string xustr;
> > > > byte[] xutest;
> > > > xustr = "CAM";
> >
> > > > //find image,cost about 1ms
> > > > xutest = ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
> >
> > > > //read byte[] into memostream,cost about 1ms
> > > > MemoryStream ms = new MemoryStream(xutest, 0, xutest.Length);
> >
> > > > //here cost 423ms to construct an bmp, what happened
> > > > here?!!!!!!!!!!!!!!!!!!!!!!!!
> > > > Bitmap bmp = new Bitmap(ms);
> >
> > > > xutest = null;
> > > > ms.Close();
> > > > GC.Collect();
> > > > GC.WaitForPendingFinalizers();
> > > > GC.Collect();
> > > > return bmp;
> > > > }
> >
> > > > Any suggestion?
> >
> > > > Thanks in advance~
> >
> > > > Regards,
> >
> > > > Freesc- Hide quoted text -
> >
> > > - Show quoted text -
> >
> > Hi,Simon
> >
> > Thanks for you reply~
> > i would remove the GC code.
> >
> > i think 400ms is unbearable because this is a video solution, it must
> > be 4 or 5 frames per secend as we expect
> > and i can not find something like Bitmap.FromStream(new
> > memorystream(...)) in .NET Compactframe , so i can not prevent
> > constructing a new bitmap when a new frame comes
> > Any suggestion about that?I have to reduce the cost , but i can't find
> > an effective way....
> > thanks again~
> >
> > Regards~- Hide quoted text -
> >
> > - Show quoted text -
>
> Oops~~~
>
> sorry about that ~ :-)
>
> each frame is an Image of 240*180 Bitmap(24bit) , we test our
> application in an XScale device of 416Mhz, 128MB ROM,64MB RAM
>
> Thanks Chris~
>
>
>
>
>
>

Re: SLOW bitmap from Stream by srhartone

srhartone
Wed Mar 12 17:50:03 CDT 2008

I would say half a second is probebly about right. You might want to try
caching the objects when loaded, but to be honest you'll probebly find
drawing them to screen using GDI is also time consuming. Worth a test though.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"Freesc" wrote:

> On Mar 8, 1:03 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
> > You didn't answer any of Simon's question. How big is the image? What
> > format is it? Color depth? What kind of device? Processor speed? RAM?
> > etc. etc. etc...
> >
> > --
> >
> > Chris Tacke, eMVP
> > Join the Embedded Developer Communityhttp://community.opennetcf.com
> >
> > "Freesc" <hjd.cl...@gmail.com> wrote in message
> >
> > news:06ce049f-ea54-42f1-926d-7f6df31055db@u10g2000prn.googlegroups.com...
> > On Mar 8, 5:10 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> >
> >
> >
> >
> >
> > > Under half a second is not that out of the ordinary loading an image on a
> > > device. How big is the image, on what device, how much RAM?
> >
> > > Calling the garbage collector is costing you, I'd get rid of that code if
> > > I
> > > were you.
> > > --
> > > Simon Hart
> > > Visual Developer - Device Application Development
> > > MVPhttp://simonrhart.blogspot.com
> >
> > > "Freesc" wrote:
> > > > Hi,there
> > > > i 'm writing an application about bitmap displaying.But i find it
> > > > works not very well because of the terrorable performance .
> >
> > > > here's my code
> >
> > > > /// <summary>
> > > > /// Get BMP according to the FrameNumber,then display
> > > > /// </summary>
> > > > /// <param name="FrameNo"></param>
> > > > /// <param name="FandR_Flag">direction</param>
> > > > /// <returns></returns>
> > > > public Bitmap createImage(int FrameNo, int FandR_Flag)
> > > > {
> > > > string xustr;
> > > > byte[] xutest;
> > > > xustr = "CAM";
> >
> > > > //find image,cost about 1ms
> > > > xutest = ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
> >
> > > > //read byte[] into memostream,cost about 1ms
> > > > MemoryStream ms = new MemoryStream(xutest, 0, xutest.Length);
> >
> > > > //here cost 423ms to construct an bmp, what happened
> > > > here?!!!!!!!!!!!!!!!!!!!!!!!!
> > > > Bitmap bmp = new Bitmap(ms);
> >
> > > > xutest = null;
> > > > ms.Close();
> > > > GC.Collect();
> > > > GC.WaitForPendingFinalizers();
> > > > GC.Collect();
> > > > return bmp;
> > > > }
> >
> > > > Any suggestion?
> >
> > > > Thanks in advance~
> >
> > > > Regards,
> >
> > > > Freesc- Hide quoted text -
> >
> > > - Show quoted text -
> >
> > Hi,Simon
> >
> > Thanks for you reply~
> > i would remove the GC code.
> >
> > i think 400ms is unbearable because this is a video solution, it must
> > be 4 or 5 frames per secend as we expect
> > and i can not find something like Bitmap.FromStream(new
> > memorystream(...)) in .NET Compactframe , so i can not prevent
> > constructing a new bitmap when a new frame comes
> > Any suggestion about that?I have to reduce the cost , but i can't find
> > an effective way....
> > thanks again~
> >
> > Regards~- Hide quoted text -
> >
> > - Show quoted text -
>
> Oops~~~
>
> sorry about that ~ :-)
>
> each frame is an Image of 240*180 Bitmap(24bit) , we test our
> application in an XScale device of 416Mhz, 128MB ROM,64MB RAM
>
> Thanks Chris~
>
>
>
>
>
>

Re: SLOW bitmap from Stream by Freesc

Freesc
Thu Mar 13 02:18:56 CDT 2008

On Mar 13, 6:51=A0am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> I forgot to mention you arn't using anything stupid such as directX are yo=
u,
> I'm assuming GDI.
> --
> Simon Hart
> Visual Developer - Device Application Development MVPhttp://simonrhart.blo=
gspot.com
>
>
>
> "Freesc" wrote:
> > On Mar 8, 1:03 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
> > > You didn't answer any of Simon's question. How big is the image? =A0Wh=
at
> > > format is it? =A0Color depth? What kind of device? =A0Processor speed?=
RAM?
> > > etc. etc. etc...
>
> > > --
>
> > > Chris Tacke, eMVP
> > > Join the Embedded Developer Communityhttp://community.opennetcf.com
>
> > > "Freesc" <hjd.cl...@gmail.com> wrote in message
>
> > >news:06ce049f-ea54-42f1-926d-7f6df31055db@u10g2000prn.googlegroups.com.=
..
> > > On Mar 8, 5:10 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
>
> > > > Under half a second is not that out of the ordinary loading an image=
on a
> > > > device. How big is the image, on what device, how much RAM?
>
> > > > Calling the garbage collector is costing you, I'd get rid of that co=
de if
> > > > I
> > > > were you.
> > > > --
> > > > Simon Hart
> > > > Visual Developer - Device Application Development
> > > > MVPhttp://simonrhart.blogspot.com
>
> > > > "Freesc" wrote:
> > > > > Hi,there
> > > > > i 'm writing an application about bitmap displaying.But i find it
> > > > > works not very well because of the terrorable performance .
>
> > > > > here's my code
>
> > > > > /// <summary>
> > > > > /// Get BMP according to the FrameNumber,then display
> > > > > /// </summary>
> > > > > /// <param name=3D"FrameNo"></param>
> > > > > /// <param name=3D"FandR_Flag">direction</param>
> > > > > /// <returns></returns>
> > > > > public Bitmap createImage(int FrameNo, int FandR_Flag)
> > > > > {
> > > > > string xustr;
> > > > > byte[] xutest;
> > > > > xustr =3D "CAM";
>
> > > > > //find image,cost about 1ms
> > > > > xutest =3D ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
>
> > > > > //read byte[] into memostream,cost about 1ms
> > > > > MemoryStream ms =3D new MemoryStream(xutest, 0, xutest.Length);
>
> > > > > //here cost 423ms to construct an bmp, what happened
> > > > > here?!!!!!!!!!!!!!!!!!!!!!!!!
> > > > > Bitmap bmp =3D new Bitmap(ms);
>
> > > > > xutest =3D null;
> > > > > ms.Close();
> > > > > GC.Collect();
> > > > > GC.WaitForPendingFinalizers();
> > > > > GC.Collect();
> > > > > return bmp;
> > > > > }
>
> > > > > Any suggestion?
>
> > > > > Thanks in advance~
>
> > > > > Regards,
>
> > > > > Freesc- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > Hi,Simon
>
> > > Thanks for you reply~
> > > i would remove the GC code.
>
> > > =A0i think 400ms is unbearable because this is a video solution, it mu=
st
> > > be 4 or 5 frames per secend as we expect
> > > and i can not find something like Bitmap.FromStream(new
> > > memorystream(...)) in .NET Compactframe , so i can not prevent
> > > constructing a new bitmap when a new frame comes
> > > Any suggestion about that?I have to reduce the cost , but i can't find=

> > > an effective way....
> > > thanks again~
>
> > > Regards~- Hide quoted text -
>
> > > - Show quoted text -
>
> > Oops~~~
>
> > sorry about that ~ =A0 :-)
>
> > each frame is an Image of =A0240*180 Bitmap(24bit) , we test our
> > application in an XScale device of 416Mhz, 128MB ROM,64MB RAM
>
> > Thanks Chris~- Hide quoted text -
>
> - Show quoted text -

Thanks, Simon.

anyhow, my problem was solved by compress the image before load in
frame, here's my code:


string xustr;
byte[] xutest;
xustr =3D "CAM";
xutest =3D ri.Fun_GetSpeData(xustr,FrameNo,FandR_Flag);

MemoryStream ms =3D new MemoryStream(xutest, 0, xutest.Length);

//Compress as a 200*127 image,using the ImageUtils(by OpenNETCF.org)
IBitmapImage ibi =3D ImageUtils.CreateThumbnail(ms, new Size(200,
127));

Bitmap bmp =3D ImageUtils.IBitmapImageToBitmap(ibi);
xutest =3D null;
ms.Close();
return bmp;

Thank you again, both Simon & Chris

Cheers
Freesc

Re: SLOW bitmap from Stream by Freesc

Freesc
Thu Mar 13 02:21:19 CDT 2008

On Mar 13, 3:18=A0pm, Freesc <hjd.cl...@gmail.com> wrote:
> On Mar 13, 6:51=A0am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
>
>
>
>
>
> > I forgot to mention you arn't using anything stupid such as directX are =
you,
> > I'm assuming GDI.
> > --
> > Simon Hart
> > Visual Developer - Device Application Development MVPhttp://simonrhart.b=
logspot.com
>
> > "Freesc" wrote:
> > > On Mar 8, 1:03 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
> > > > You didn't answer any of Simon's question. How big is the image? =A0=
What
> > > > format is it? =A0Color depth? What kind of device? =A0Processor spee=
d? RAM?
> > > > etc. etc. etc...
>
> > > > --
>
> > > > Chris Tacke, eMVP
> > > > Join the Embedded Developer Communityhttp://community.opennetcf.com
>
> > > > "Freesc" <hjd.cl...@gmail.com> wrote in message
>
> > > >news:06ce049f-ea54-42f1-926d-7f6df31055db@u10g2000prn.googlegroups.co=
m...
> > > > On Mar 8, 5:10 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
>
> > > > > Under half a second is not that out of the ordinary loading an ima=
ge on a
> > > > > device. How big is the image, on what device, how much RAM?
>
> > > > > Calling the garbage collector is costing you, I'd get rid of that =
code if
> > > > > I
> > > > > were you.
> > > > > --
> > > > > Simon Hart
> > > > > Visual Developer - Device Application Development
> > > > > MVPhttp://simonrhart.blogspot.com
>
> > > > > "Freesc" wrote:
> > > > > > Hi,there
> > > > > > i 'm writing an application about bitmap displaying.But i find i=
t
> > > > > > works not very well because of the terrorable performance .
>
> > > > > > here's my code
>
> > > > > > /// <summary>
> > > > > > /// Get BMP according to the FrameNumber,then display
> > > > > > /// </summary>
> > > > > > /// <param name=3D"FrameNo"></param>
> > > > > > /// <param name=3D"FandR_Flag">direction</param>
> > > > > > /// <returns></returns>
> > > > > > public Bitmap createImage(int FrameNo, int FandR_Flag)
> > > > > > {
> > > > > > string xustr;
> > > > > > byte[] xutest;
> > > > > > xustr =3D "CAM";
>
> > > > > > //find image,cost about 1ms
> > > > > > xutest =3D ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
>
> > > > > > //read byte[] into memostream,cost about 1ms
> > > > > > MemoryStream ms =3D new MemoryStream(xutest, 0, xutest.Length);
>
> > > > > > //here cost 423ms to construct an bmp, what happened
> > > > > > here?!!!!!!!!!!!!!!!!!!!!!!!!
> > > > > > Bitmap bmp =3D new Bitmap(ms);
>
> > > > > > xutest =3D null;
> > > > > > ms.Close();
> > > > > > GC.Collect();
> > > > > > GC.WaitForPendingFinalizers();
> > > > > > GC.Collect();
> > > > > > return bmp;
> > > > > > }
>
> > > > > > Any suggestion?
>
> > > > > > Thanks in advance~
>
> > > > > > Regards,
>
> > > > > > Freesc- Hide quoted text -
>
> > > > > - Show quoted text -
>
> > > > Hi,Simon
>
> > > > Thanks for you reply~
> > > > i would remove the GC code.
>
> > > > =A0i think 400ms is unbearable because this is a video solution, it =
must
> > > > be 4 or 5 frames per secend as we expect
> > > > and i can not find something like Bitmap.FromStream(new
> > > > memorystream(...)) in .NET Compactframe , so i can not prevent
> > > > constructing a new bitmap when a new frame comes
> > > > Any suggestion about that?I have to reduce the cost , but i can't fi=
nd
> > > > an effective way....
> > > > thanks again~
>
> > > > Regards~- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > Oops~~~
>
> > > sorry about that ~ =A0 :-)
>
> > > each frame is an Image of =A0240*180 Bitmap(24bit) , we test our
> > > application in an XScale device of 416Mhz, 128MB ROM,64MB RAM
>
> > > Thanks Chris~- Hide quoted text -
>
> > - Show quoted text -
>
> Thanks, Simon.
>
> anyhow, my problem was solved by compress the image before load in
> frame, here's my code:
>
> string xustr;
> byte[] xutest;
> xustr =3D "CAM";
> xutest =3D ri.Fun_GetSpeData(xustr,FrameNo,FandR_Flag);
>
> MemoryStream ms =3D new MemoryStream(xutest, 0, xutest.Length);
>
> //Compress as a 200*127 image,using the ImageUtils(by OpenNETCF.org)
> IBitmapImage ibi =3D ImageUtils.CreateThumbnail(ms, new Size(200,
> 127));
>
> Bitmap bmp =3D ImageUtils.IBitmapImageToBitmap(ibi);
> xutest =3D null;
> ms.Close();
> return bmp;
>
> Thank you again, both Simon & Chris
>
> Cheers
> Freesc- Hide quoted text -
>
> - Show quoted text -

and now it cost me just 150ms to load the bmp:)

Regards

Re: SLOW bitmap from Stream by srhartone

srhartone
Thu Mar 13 09:59:03 CDT 2008

Interesting code, thanks for posting it.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"Freesc" wrote:

> On Mar 13, 3:18 pm, Freesc <hjd.cl...@gmail.com> wrote:
> > On Mar 13, 6:51 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> >
> >
> >
> >
> >
> > > I forgot to mention you arn't using anything stupid such as directX are you,
> > > I'm assuming GDI.
> > > --
> > > Simon Hart
> > > Visual Developer - Device Application Development MVPhttp://simonrhart.blogspot.com
> >
> > > "Freesc" wrote:
> > > > On Mar 8, 1:03 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
> > > > > You didn't answer any of Simon's question. How big is the image? What
> > > > > format is it? Color depth? What kind of device? Processor speed? RAM?
> > > > > etc. etc. etc...
> >
> > > > > --
> >
> > > > > Chris Tacke, eMVP
> > > > > Join the Embedded Developer Communityhttp://community.opennetcf.com
> >
> > > > > "Freesc" <hjd.cl...@gmail.com> wrote in message
> >
> > > > >news:06ce049f-ea54-42f1-926d-7f6df31055db@u10g2000prn.googlegroups.com...
> > > > > On Mar 8, 5:10 am, Simon Hart [MVP] <srhart...@yahoo.com> wrote:
> >
> > > > > > Under half a second is not that out of the ordinary loading an image on a
> > > > > > device. How big is the image, on what device, how much RAM?
> >
> > > > > > Calling the garbage collector is costing you, I'd get rid of that code if
> > > > > > I
> > > > > > were you.
> > > > > > --
> > > > > > Simon Hart
> > > > > > Visual Developer - Device Application Development
> > > > > > MVPhttp://simonrhart.blogspot.com
> >
> > > > > > "Freesc" wrote:
> > > > > > > Hi,there
> > > > > > > i 'm writing an application about bitmap displaying.But i find it
> > > > > > > works not very well because of the terrorable performance .
> >
> > > > > > > here's my code
> >
> > > > > > > /// <summary>
> > > > > > > /// Get BMP according to the FrameNumber,then display
> > > > > > > /// </summary>
> > > > > > > /// <param name="FrameNo"></param>
> > > > > > > /// <param name="FandR_Flag">direction</param>
> > > > > > > /// <returns></returns>
> > > > > > > public Bitmap createImage(int FrameNo, int FandR_Flag)
> > > > > > > {
> > > > > > > string xustr;
> > > > > > > byte[] xutest;
> > > > > > > xustr = "CAM";
> >
> > > > > > > //find image,cost about 1ms
> > > > > > > xutest = ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
> >
> > > > > > > //read byte[] into memostream,cost about 1ms
> > > > > > > MemoryStream ms = new MemoryStream(xutest, 0, xutest.Length);
> >
> > > > > > > //here cost 423ms to construct an bmp, what happened
> > > > > > > here?!!!!!!!!!!!!!!!!!!!!!!!!
> > > > > > > Bitmap bmp = new Bitmap(ms);
> >
> > > > > > > xutest = null;
> > > > > > > ms.Close();
> > > > > > > GC.Collect();
> > > > > > > GC.WaitForPendingFinalizers();
> > > > > > > GC.Collect();
> > > > > > > return bmp;
> > > > > > > }
> >
> > > > > > > Any suggestion?
> >
> > > > > > > Thanks in advance~
> >
> > > > > > > Regards,
> >
> > > > > > > Freesc- Hide quoted text -
> >
> > > > > > - Show quoted text -
> >
> > > > > Hi,Simon
> >
> > > > > Thanks for you reply~
> > > > > i would remove the GC code.
> >
> > > > > i think 400ms is unbearable because this is a video solution, it must
> > > > > be 4 or 5 frames per secend as we expect
> > > > > and i can not find something like Bitmap.FromStream(new
> > > > > memorystream(...)) in .NET Compactframe , so i can not prevent
> > > > > constructing a new bitmap when a new frame comes
> > > > > Any suggestion about that?I have to reduce the cost , but i can't find
> > > > > an effective way....
> > > > > thanks again~
> >
> > > > > Regards~- Hide quoted text -
> >
> > > > > - Show quoted text -
> >
> > > > Oops~~~
> >
> > > > sorry about that ~ :-)
> >
> > > > each frame is an Image of 240*180 Bitmap(24bit) , we test our
> > > > application in an XScale device of 416Mhz, 128MB ROM,64MB RAM
> >
> > > > Thanks Chris~- Hide quoted text -
> >
> > > - Show quoted text -
> >
> > Thanks, Simon.
> >
> > anyhow, my problem was solved by compress the image before load in
> > frame, here's my code:
> >
> > string xustr;
> > byte[] xutest;
> > xustr = "CAM";
> > xutest = ri.Fun_GetSpeData(xustr,FrameNo,FandR_Flag);
> >
> > MemoryStream ms = new MemoryStream(xutest, 0, xutest.Length);
> >
> > //Compress as a 200*127 image,using the ImageUtils(by OpenNETCF.org)
> > IBitmapImage ibi = ImageUtils.CreateThumbnail(ms, new Size(200,
> > 127));
> >
> > Bitmap bmp = ImageUtils.IBitmapImageToBitmap(ibi);
> > xutest = null;
> > ms.Close();
> > return bmp;
> >
> > Thank you again, both Simon & Chris
> >
> > Cheers
> > Freesc- Hide quoted text -
> >
> > - Show quoted text -
>
> and now it cost me just 150ms to load the bmp:)
>
> Regards
>