Pregunta

I use the class ImageHelper who was quoted in the article of Chris Tacke to resize large images on Compact Framework, using OpenNetCF.Drawing namespace. In many devices that have Windows Mobile 6.5 version Embebbed the class worked perfectly. However in some devices with the Windows Mobile version 6.1 (robust Honeywell equipment) and HTC T3333 (Touch2) throws an exception "0x887b0005". Is there any limitation on the use of this device? There is an alternative to solve this problem?

¿Fue útil?

Solución

0x887B0005 is a COM error that I've generally seen only when the image you're trying to show is using a color format that isn't supported by the Compact Framework. This might work around the issue:

IBitmapImage imageBitmap;
ImageInfo imageInfo;
IImage image;

var imageFactory = new ImagingFactoryClass();
imageFactory.CreateImageFromStream(new StreamOnFile(fileStream), out image);
image.GetImageInfo(out imageInfo);

//verify we're a CF-supported image format
if (imageInfo.PixelFormat != PixelFormat.Format16bppRgb555 
    && imageInfo.PixelFormat != PixelFormat.Format16bppRgb565 
    && imageInfo.PixelFormat != PixelFormat.Format24bppRgb 
    && imageInfo.PixelFormat != PixelFormat.Format32bppRgb)
{
    imageInfo.PixelFormat = PixelFormat.Format24bppRgb; 
}

imageFactory.CreateBitmapFromImage(
             image,  
             (uint)width, 
             (uint)height, 
             imageInfo.PixelFormat, 
             InterpolationHint.InterpolationHintDefault, 
             out imageBitmap);

var bmp = ImageUtils.IBitmapImageToBitmap(imageBitmap);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top