slow bitmap from Stream

Last post 03-26-2008 20:48 by hellobaobao. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-24-2008 2:55

    slow bitmap from Stream

    /// <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 .ths original image is 752*480
    xutest = ri.Fun_GetSpeData(xustr, FrameNo, FandR_Flag);
    //read byte[] into MemoryStream,cost about 1ms
    MemoryStream ms = new MemoryStream(xutest, 0, xutest.Length);
    //Compress 752*480 as a 200*127 image,here cost 223ms.I wanted this step cost less times,how can I do?
    IBitmapImage ibi = ImageUtils.CreateThumbnail(ms, new Size(200, 127));  

    //cost about 4ms     
    Bitmap bmp = ImageUtils.IBitmapImageToBitmap(ibi);
    xutest = null;
    ms.Close();
    return bmp;
    }
    Thanks!

  • 03-25-2008 3:59 In reply to

    • Neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: slow bitmap from Stream

    A quick bit of mathematics will show that 223ms is reasonable in this scenario. An image that is 752x480 contains 360960 pixels. Depending on the resolution (8, 16, or 24 bits per pixel), the image could be anything from 350KB to just over 1MB. Take the worse case scenario of a 24-bit image, the size of the image will be 1082880 bytes.

    Rather than reading the whole 1082880 bytes into the MemoryStream in one go, you can get a (marginal) performance improvement by reading the data in 64KB chunks. This is because the page size is 64KB and it is far more efficient to allocate whole pages that partial pages.


  • 03-25-2008 4:49 In reply to

    Re: slow bitmap from Stream

     

    thanks neil.if I Create Thumbnail bitmap(320*204)  the program will cost 350ms but my player need display image

    at least 4 Frame/s.So I wanted the Step "IBitmapImage ibi = ImageUtils.CreateThumbnail(ms, new Size(320, 204));  "  can cost less time. my bitmap is 24 bits per pixel how can  I reduce the bitmap size use set the pixel.To excuse for my bad english.

     

     

  • 03-25-2008 4:56 In reply to

    • Neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: slow bitmap from Stream

    hellobaobao:
    how can  I reduce the bitmap size use set the pixel

    I don't understand the question.


  • 03-26-2008 20:48 In reply to

    Re: slow bitmap from Stream

    To excuse for my bad english,my question is how can I improve the speed of display image.
    thank you!

Page 1 of 1 (5 items)