Windows mobile 5, imgdecmp.dll fix1
2
3
4
5
6
7
8
9
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
1
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.
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.)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.
But other pages state that it does .png, .gif, .jpg, etc...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
);