all groups > dotnet compact framework > july 2005 >
You're in the

dotnet compact framework

group:

Displaying JPG Images with .NET CF impossible?



Displaying JPG Images with .NET CF impossible? xalex
7/30/2005 11:42:47 PM
dotnet compact framework: Hi,
we are developing an application that lets you annotate your Images on
the compact flash card of your
digital camera to store the images wirh annotations later in an image
database.
i want to show large JPGs (or only the thumbsnails containing in the
larger imagges) with the code below:

Bitmap bm = new Bitmap(filename);
imageBox.Image = bm;

Small jpg are shown perfectly, larger files (3megapixel or more) cause
the system.drawing.dll throw
an exception (unknonw exception with the helpful message 'Exception' )

I browsed the web and found the infos below about imgdecmp.dll and the
undocumented APIs
SHLoadImageFile and SHLoadImageResource

It cant be true, that it isnt possible to display images with Compact
Framework (1.1)
Is there an open or cloed source library that supports displaying jpgs?

Thanks,
Alex

--
Alexander Ramisch mailto:info@pixafe.com
pixafe GbR http://www.pixafe.com


Infos about the undocumented API:
Windows Mobile devices have traditionally included a ROM library called
imgdecmp.dll for Microsoft applications to use. This library exported
an API that was not documented in the SDK, but it has been used by
developers to load image files. Starting with Windows Mobile 2003
Second Edition, SHLoadImageFile and SHLoadImageResource were added
into the headers for aygshell.h. These APIs should be used in place of
imaging support previously provided by imgdecmp.dll. Alternatively,
advanced imaging APIs are provided by imaging.h for applications
targeting Windows Mobile 5.0 or later. On Windows Mobile 5.0,
applications may get caught in an infinite loop if they call the
DecompressImageIndirect function with a DecompressImageInfo structure
with a prepopulated buffer and without specifying a correct non-zero
value for dwBufferCurrent. Note Imgdecmp.dll will be removed from a
future version of the Windows Mobile platform.
Re: Displaying JPG Images with .NET CF impossible? Peter Kellner
7/31/2005 12:00:00 AM
This followup was posted to
microsoft.public.dotnet.framework.compactframework

In article <#xIrEJjlFHA.3256@tk2msftngp13.phx.gbl>,
public_news@alexfeinman.com says...
[quoted text, click to view]

I was hoping for a .net example that calls the DLL. I've never done
anything in the CE environment with c or c++ and am hoping not to have
to.

Thanks
--
Peter Kellner
Re: Displaying JPG Images with .NET CF impossible? Peter Kellner
7/31/2005 12:00:00 AM


In article <Ot166yalFHA.3316@TK2MSFTNGP14.phx.gbl>,
public_news@alexfeinman.com says...
[quoted text, click to view]

I' really appreciate it if you would post a small piece of code showing
an example of using SHLoadImageFile to create a viewable image (ie,
small image)

Thanks

--
Peter Kellner
Re: Displaying JPG Images with .NET CF impossible? Alex Feinman [MVP]
7/31/2005 1:50:57 AM
I'm not sure why you call SHLoadImageFile an undocumented API - what about
http://msdn.microsoft.com/library/en-us/apippc/html/ppc__mdref_shloadimagefile.asp ?
A 3 megapixel JPEG indeed may have problems being opened using Bitmap class,
since the uncompressed bitmap is over 6 MB
As for 3rd party JPEG library, perhaps this can be of some help (I haven't
tried it) http://www.pocketpcdn.com/articles/jpeglib.html

--
Alex Feinman
---
Visit http://www.opennetcf.org
[quoted text, click to view]
Re: Displaying JPG Images with .NET CF impossible? Alex Feinman [MVP]
7/31/2005 10:56:33 AM
SHLoadImageFile is not capable of creating a preview bitmap if that's what
you mean. It will attempt to load the whole image, sufferring from the same
limitaitons as Bitmap constructor. The Bitmap constructor internally call
SHLoadImageFile (SP2 and newer. RTM and SP1 used DecompressImageIndirect)

--
Alex Feinman
---
Visit http://www.opennetcf.org
[quoted text, click to view]
Re: Displaying JPG Images with .NET CF impossible? Alex Feinman [MVP]
7/31/2005 5:46:52 PM
Take a look at this page:
http://www.unsupportedsoftware.com/ce/dev/imgdecmp.htm

The MaxWidth and MaxHeight are supposedly used to limit generated bitmap
size

--
Alex Feinman
---
Visit http://www.opennetcf.org
[quoted text, click to view]
Re: Displaying JPG Images with .NET CF impossible? Peter Kellner
7/31/2005 6:08:12 PM
This followup was posted to
microsoft.public.dotnet.framework.compactframework

In article <uQVKzjflFHA.3288@TK2MSFTNGP09.phx.gbl>,
public_news@alexfeinman.com says...
[quoted text, click to view]

I'm still very interested if there is a example out there using C#
(possibly using DecompressImageIndirect) that will let me retrieve a
large image (3MB's or so) and create a preview bitmap.

Thanks


--
Peter Kellner
Re: Displaying JPG Images with .NET CF impossible? Alex Feinman [MVP]
7/31/2005 9:13:06 PM
Sorry, this kind of things cannot be done entirely in .NET. Even in CF 2.0
someone will have to write interop code. Here is a starting point if you
decide to have a go at it:

extern "C" int LoadThumbnail(LPCTSTR szImage, int cx, int cy)

{

CoInitializeEx(NULL, COINIT_MULTITHREADED);

{

CComPtr<IImagingFactory>pFactory;

CComPtr<IImage>pImg;

CComPtr<IImage>pThumbImage;

pFactory.CoCreateInstance(CLSID_ImagingFactory);

HRESULT hr = pFactory->CreateImageFromFile(szImage, &pImg);

if ( FAILED ( hr ) )

return hr;

hr = pImg->GetThumbnail(cx, cy, &pThumbImage);

if ( FAILED ( hr ) )

return hr;

CComPtr<IBitmapImage>pBitmap;

hr = pFactory->CreateBitmapFromImage(pThumbImage, cx, cy,
PIXFMT_16BPP_RGB565, InterpolationHintDefault, &pBitmap);

if ( FAILED ( hr ) )

return hr;

RECT rc = { 0, 0, cx, cy };

BitmapData data;

hr = pBitmap->LockBits(&rc, ImageLockModeRead, PixelFormat16bppRGB565,
&data);

// Add here code that creates BITMAPFILEHEADER and the rest of data
structures and generates a byte array suitable for using with Bitmap
constructor

}

CoUninitialize();

return 0;

}


--
Alex Feinman
---
Visit http://www.opennetcf.org
[quoted text, click to view]
AddThis Social Bookmark Button