How to load the high resolution images in windows mobile

主宰稳场 提交于 2019-12-13 08:03:44

问题


Can any one tell me, how to load the high resolution images in windows mobile using C#. I am getting OutOfMemoryException for that.


回答1:


Use IImagingFactory and IImage, they are com objects that were introduced in WCE 5.0.

You will have to write com wrappers for them, or use OpenNETCF which has them already.

See here for a blog post from Chris Lorton on alphablending and the imaging factory classes and how to use them from .net




回答2:


This code shows a form with a 2mb jpg image (3000x2000 or so) on a form at 240x320, without any OOM exceptions. Obviously you will need to tidy it up to dispose of the bmp and release the com objects etc. but it does work and I have tried it on the wm6.5 emulator.

public partial class Form1 : Form
{
    IImage smallImage;
    Bitmap bmp = new Bitmap(240, 320);

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        IImage fullSizeImage;
        IImagingFactory factory = new ImagingFactoryClass();
        factory.CreateImageFromFile(@"\My Documents\My Pictures\luminous opera house.jpg", out fullSizeImage);

        fullSizeImage.GetThumbnail(240, 320, out smallImage);

        using (Graphics gfx = Graphics.FromImage(bmp))
        {
            IntPtr hdc = gfx.GetHdc();
            try
            {
                smallImage.Draw(hdc, new Rectangle(0, 0, 240, 320), IntPtr.Zero);
            }
            finally
            {
                gfx.ReleaseHdc(hdc);
            }
        }
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        e.Graphics.DrawImage(bmp, 0, 0);
    }
}



回答3:


Here's a blog entry that covers loading large images and then zooming in on parts of them.



来源:https://stackoverflow.com/questions/1490652/how-to-load-the-high-resolution-images-in-windows-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!