0

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?

Julio Borges
  • 661
  • 14
  • 29

1 Answers1

2

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);
ctacke
  • 66,480
  • 18
  • 94
  • 155
  • Thanks Chris, after your reply, I realized that the problem was that I was using the images. Because they were captured by the scanner device and the device was unknown pixelFormat and caused the error. Thank you! – Julio Borges Sep 06 '12 at 18:10
  • [Chris](http://stackoverflow.com/users/13154/ctacke) I'm facing a small problem now, in some WM devices only when I debug on the method mentioned above, I get an exception "The method or operation is not implemented." line. CreateImageFromStream (... and on line CreateBitmapFromImage (.... If I continue running (F5) the execution occurs normally. There is a chance this exception cause me any future problem? – Julio Borges Jul 08 '13 at 11:23
  • I've never seen that exception when using this code, so I don't know if it will have any potential future impact. – ctacke Jul 08 '13 at 14:59
  • Ok [Chris](http://stackoverflow.com/users/13154/ctacke) ! I'll be testing with different equipment to see if there is any risk. If something unusual happens I will be reporting through this issue. Thank you! – Julio Borges Jul 08 '13 at 20:31
  • If I were to guess, the source pixel format is unsupported, but when you explicitly set it to something supported, the thumbnail gets created fine. – ctacke Oct 18 '13 at 15:30