Hello,
I have an application using KOL-CE and compiled for ARM pocket pcs.
I need to display a jpg image.
My target is PPC2003, Windows Mobile 5, Windows Mobile 6.
Currently I can show a .2bp file using the following code in the onPaint event of the KOLPaintBox component:
procedure TfMain.bBackgroundPaint(sender: pcontrol; DC: HDC);
var BitMap:pBitmap; aRect: tRect;
begin
BitMap:=NewBitMap(0,0);
Bitmap^.LoadfromFile('test.2bp');
aRect.Left:= 0;
aRect.Top := 0;
aRect.Right := sender^.width;
aRect.Bottom := sender^.height;
Bitmap.StretchDraw (DC,aRect);
end;
I considered using the windows api
function SHLoadImageFile(pszFileName: LPCTSTR ) : HBITMAP; external 'imgdecmp.dll' name 'SHLoadImageFile';
but it seems this is not available on al ppcs, especially recent ones.
If the dll is not present the application will not load at all. So this is another option to rule out.
Finally, it seems nearly all pocket pcs currently available support Imaging Factory,
http://ce4all.blogspot.com/2007/06/using-image-factory-under-cewindows.htmlso this code could help (but first we need to port it to pascal):
CoInitializeEx(NULL, 0);
IImagingFactory* pImageFactory;
IImage *pImage = NULL;
HDC dc = GetDC(0); // insert your window handle here, else this is the desktop
HRESULT hr = CoCreateInstance(CLSID_ImagingFactory, NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IImagingFactory),
(LPVOID *)&pImageFactory);
// Load image from file
pImageFactory->CreateImageFromFile(bitmapName, &pImage);
// Get image information
ImageInfo info;
pImage->GetImageInfo(&info);
RECT rc={0,0,info.Width, info.Height};
// draw jpg/gif etc onto temp dc
pImage->Draw(dc, &rc, NULL);
// Clean up
pImage->Release();
pImageFactory->Release();
CoUninitialize();
If someone can help with the code, I can test on several pocket pcs.