Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Windows mobile 5, imgdecmp.dll fix


Windows mobile 5, imgdecmp.dll fix

Postby Jaimi » Sep 30, 2005 @ 2:44am

Hi -

I've made a fix for DecompressImage() so that it works on windows mobile 5. This uses the IImagingFactory interface that was introduced in the Windows Mobile 2003 sdk, and no longer needs the imgdecmp.dll.

Is anyone interested in the changes? The IImagingFactory interface dates back to 1999, and should work on all devices.
Jaimi
pm Member
 
Posts: 12
Joined: Sep 29, 2005 @ 5:23pm


Postby BIGBEN » Sep 30, 2005 @ 3:39am

Sure :D

You can see it from this thread:

Problem with image loading in the future?

You can include my Bugfix if you want to ;)

Or I can include your code in bugfix as PF improvement, if you don't mind.

You said 2003 SDK, does this mean it wouldn't work on 2000 and 2002 devices?
Or you check WM version to use this method only on WM 5 devices?
Last edited by BIGBEN on Sep 30, 2005 @ 4:22am, edited 1 time in total.
User avatar
BIGBEN
pm Member
 
Posts: 281
Joined: Mar 18, 2003 @ 10:18pm
Location: Saint-Petersburg, Russia


Postby Jaimi » Sep 30, 2005 @ 3:56am

I believe that it will work on older devices, but I'm not sure. MS posted that it used to be internal-only, but that it has been around since 1999. It's now officially supported, but it definitely works on 2003 and WM 5. I don't have a previous device to test it on though. Since it seemed likely that it would work going way back, and since imgdecomp.dll is not shipped on all devices (and blows up in WM5), I just went ahead and removed it.

Here are the changes:

game.cpp - Need to init COM. The constructor and destructor are modified.
Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
Game::Game()
{
    CoInitializeEx(NULL, COINIT_MULTITHREADED);
    ... rest of constructor goes here.
}

Game::~Game()
{
    CoUninitialize();
}

--------------------------------------------

image.cpp - remove imgdecmp, replace with IImagingFactory:

// replace define line 24
#ifdef _WIN32_WCE
   #include "foreign/imgdecmp/imgrendr.h"
   #include <INITGUID.h>
   #include <imaging.h>
   #pragma comment( lib, "ole32.lib" )
#else

---------------------------------------------
image.cpp - add after DecompressImage(hBitmap)

// Create a surface from a IImage
static Surface* CreateSurface( IImage *img )
{
   // Retrieve bitmap info
   ImageInfo iInfo;

   HRESULT hr = img->GetImageInfo(&iInfo);
   if (FAILED(hr))
     {
     // FileLog("Failed getting image info...",hr);
     return NULL;
     }

   // Create the surface
   Surface* surface = new Surface( iInfo.Width, iInfo.Height );

   // Blit the bitmap on the surface
   HDC hDestDC = surface->GetDC( true );

   RECT rc;
   rc.left   = 0;
   rc.top    = 0;
   rc.right  = iInfo.Width;
   rc.bottom = iInfo.Height;

   img->Draw(hDestDC,&rc,NULL);

   surface->ReleaseDC( hDestDC );
   //FileLog("Returning surface...",0);
   return surface;
}

------------------------------------------------
Replace DecompressImage

static Surface* DecompressImage( const uint8_t* pBegin, const uint8_t* pEnd )
{
   //FileLog("Decompressing Image",0);
   // This will be filled with a handle to the image
   HBITMAP hBitmap = 0;

   // CComPtr should auto release.
   CComPtr<IImagingFactory>pFactory;
   HRESULT hr = pFactory.CoCreateInstance(CLSID_ImagingFactory);
   if ( SUCCEEDED(hr) )
   {
     CComPtr<IImage>pImg;
     hr = pFactory->CreateImageFromBuffer((const void *)pBegin, pEnd-pBegin, BufferDisposalFlagNone, &pImg);
     if (FAILED(hr))
       {
           // FileLog("CreateImageFromBuffer failed",hr);
       return 0;
       }
     return CreateSurface(pImg);
    }
    else
    {
    //FileLog("IImageFactory failed",hr);
    }
   return 0;
}
87 lines; 23 keywds; 5 nums; 296 ops; 2 strs; 12 coms    Syntactic Coloring v0.4 - Dan East  
Jaimi
pm Member
 
Posts: 12
Joined: Sep 29, 2005 @ 5:23pm


Postby Jaimi » Sep 30, 2005 @ 3:58am

Sorry - it seems to have deleted all of the spacing...
Jaimi
pm Member
 
Posts: 12
Joined: Sep 29, 2005 @ 5:23pm


Postby fast_rx » Sep 30, 2005 @ 4:14am

Use the code tags for code...
Code: Select all

like this
1 lines; 1 keywds; 0 nums; 0 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


If you wanted to see if it works with older devices, post an exe and have us test it.
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby BIGBEN » Sep 30, 2005 @ 4:32am

I can test it on my MIPS Cassiopea E-125 and ARM(XScale) A620BT ;)

If you use only eVC 4.0, I can help you to compile and test it with eVC 3.0 (PPC 2000 MIPS and ARM SDK's)
User avatar
BIGBEN
pm Member
 
Posts: 281
Joined: Mar 18, 2003 @ 10:18pm
Location: Saint-Petersburg, Russia


Postby Jaimi » Sep 30, 2005 @ 4:44am

if you wanted to see if it works with older devices, post an exe and have us test it.


I can post a WM2003 version for ARM. Would that work on earlier devices?
Attachments
supersample.zip
(33.36 KiB) Downloaded 1025 times
Jaimi
pm Member
 
Posts: 12
Joined: Sep 29, 2005 @ 5:23pm


Postby Jaimi » Sep 30, 2005 @ 4:46am

If you use only eVC 4.0, I can help you to compile and test it with eVC 3.0 (PPC 2000 MIPS and ARM SDK's)


Sure - want me to post my modified PF project? Or do you want to apply the "code patch" I posted above?
Jaimi
pm Member
 
Posts: 12
Joined: Sep 29, 2005 @ 5:23pm


Postby BIGBEN » Sep 30, 2005 @ 6:37am

Can you, please, PM me or post your project+modified PF files in one zip ;)

Supersample works on Asus A620BT (PocketPC 2003)
User avatar
BIGBEN
pm Member
 
Posts: 281
Joined: Mar 18, 2003 @ 10:18pm
Location: Saint-Petersburg, Russia


Postby Slim » Sep 30, 2005 @ 8:23am

Jaimi, I'd rather see that you post your modified PF-project+files here in the forum so that everyone can have a look at it.

Regards
Slim
pm Member
 
Posts: 17
Joined: Aug 30, 2004 @ 3:04pm
Location: Sweden


Postby Jaimi » Sep 30, 2005 @ 9:14pm

I'll zip up the project and post it here when I get home this evening.
Jaimi
pm Member
 
Posts: 12
Joined: Sep 29, 2005 @ 5:23pm


Postby Presto » Sep 30, 2005 @ 10:25pm

Coincidentally I just finished up my changes to PocketFrog to use SHLoadImageFile and SHLoadImageResource.

These changes work without requiring any extra stuff, including the IImagingFactory interface. Since both of the SHLoadImage functions return HBITMAPs, and there's already a CreateSurface() function that takes an HBITMAP, it's much cleaner this way.

A couple of notes:
1) Download the right version ( PF 0.7 or 0.8 )
2) SHLoadImageResource only seems to look for images in a "GIF" resource folder... pretty flippin' ignorant of Microsoft... so I changed the default from "image" to "GIF" in image.h.
3) Only PPC 2002 and above support SHLoadImage, so you'll have to drop support for PPC 2000. (But I don't think anyone will have a problem with that.)

http://www.pocketadventures.com/downloa ... ge_src.zip
http://www.pocketadventures.com/downloa ... ge_src.zip

-John

[EDIT: The files at PM vanished, and the upload utility isn't working, so I'm hosting them at PocketAdventures.com.]
Last edited by Presto on Nov 20, 2006 @ 4:18am, edited 5 times in total.
<a href="http://www.pocketadventures.com/travel.asp"><img src="http://www.pocketadventures.com/images/ttc_banner.gif" border="0"></a>
User avatar
Presto
pm Insider
 
Posts: 763
Joined: Jan 20, 2003 @ 5:51am
Location: Kalesian Archipelago


Postby Jaimi » Oct 1, 2005 @ 12:58am

Just to set it straight, the IImagingFactory code doesn't require any new stuff either -- it's been built into the operating system since 1999.

Not saying that people shouldn't use yours (or that mine is better), but for me, the reason that I choose IImagingFactory over SHLoadImageFile (besides the GIF issue), is because IImagingFactory supported loading images straight from a buffer, and was a drop-in replacement for DecompressImage. Since I wanted to support loading textures from "pak" files, I needed this functionality.

This link is my entire PocketFrog directory. It includes the latest updates to pocketfrog 0.8.1 (from BigBen) and the latest PocketHal.

http://www.aztica.com/pocketfrog.zip
Jaimi
pm Member
 
Posts: 12
Joined: Sep 29, 2005 @ 5:23pm


Postby Presto » Oct 1, 2005 @ 2:47am

Jaimi wrote:Just to set it straight, the IImagingFactory code doesn't require any new stuff either -- it's been built into the operating system since 1999.

Not saying that people shouldn't use yours (or that mine is better), but for me, the reason that I choose IImagingFactory over SHLoadImageFile (besides the GIF issue), is because IImagingFactory supported loading images straight from a buffer, and was a drop-in replacement for DecompressImage. Since I wanted to support loading textures from "pak" files, I needed this functionality.
Good point, Jaimi. The SHLoadImage functions don't work with objects in a buffer. Also, not to confuse anyone, the resource images don't have to be GIF files, they just need to be in a resource folder called GIF. (Though maybe JPG, PNG, etc work too. I haven't tried those.)
If you look at the MSDN documentation, some pages state:
MSDN wrote:Converts a .gif file in the resource file to a .bmp file. A resource .gif file should be coded in the resource file as follows: IDG_MYIMAGE_GIF GIF DISCARDABLE "MyImage.gif".

Syntax
HBITMAP SHLoadImageResource (
HINSTANCE hinst,
UINT uIdGif
);
But other pages state that it does .png, .gif, .jpg, etc...

Also, I must admit that it's nice to see the community working to make PF better. I still believe that it's the easiest library to work with, by far.
User avatar
Presto
pm Insider
 
Posts: 763
Joined: Jan 20, 2003 @ 5:51am
Location: Kalesian Archipelago


Postby BIGBEN » Oct 1, 2005 @ 6:36am

Jaimi, I tried to compile Blit and PF.libs but failed with some IImage related errors(VC6), and with one error in eVC. I have no imaging.h file, should I install some WM5 SDK's first?

Presto, I've tried your approach - changed resource type to "GIF" in supersample- works well in my VC6.

Obviously doesn't compile in eVC3.0 (PPC2000 SDK), yes I'm a dinosaur :?
User avatar
BIGBEN
pm Member
 
Posts: 281
Joined: Mar 18, 2003 @ 10:18pm
Location: Saint-Petersburg, Russia


Next

Return to PocketFrog & PocketHAL


Sort


Forum Description

SDKs for fast and robust device-independent access to Pocket PC display hardware.

Moderators:

sponge, Kzinti

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron