BREW uses Gzip compressed BMP pictures, pay machine test code Winger Everyone must take too much BMP picture to occupy too much storage space is very troubled, do simple games, picture resources also have a dozens of hundreds of hundreds K, don't tell me to use PNG, use this thing to limit it too big, don't always think about png to bmp, I think of transplantation, look at the decompression code of PNG, I will take a headache. In fact, everyone will turn over the help, it will find that 2.0 or more SDK supports the decompression object of a AEECLSID_UNZIPSTream, which is decompressed for the data compressed by Gzip. OK, think of my solution: Use GZIP to compress BMP, then use aeeclsid_unzipstream to decompress. My solution is about a few steps: 1, gzip compresses BMP, must be Gzip, WinZip, WinRar can not 2, put the compressed BMP to the resource, the method is changed to .bmp The suffix is added as a picture resource. 3. In the program, use aeeclsid_unzipstream to extract, the code is as follows:
PHP source code:
Void * unzipbmpex (mj * mj, char * res_file, uint16 id, int * w, int * h)
{
UINT32 NTMP, SIZE, L;
BYTE * BUF, * TMPBUF;
Void * pbmsource = null;
BYTE * PDATABYTES;
Void * BMP;
AeeImageInfo imageInfo;
Boolean Bval = True;
IF (null == (pbmsource = ishell_loadresdataex (mj-> a.m_pishell, res_file,
ID, RESTYPE_IMAGE, NULL, & Size))))))
{
Return NULL;
}
TMPBUF = (Byte *) Malloc (size - * ((Byte *))));
Memcpy (TMPBUF, (Byte *) PBMSource * (PBMSource), size - * ((Byte *)))));
IMEMASTREAM_SET (MJ-> Pmemstream, TmpBuf, Size - * ((Byte *) (PBMSource), 0, FALSE
l = (* (Byte *) PBMSource Size-4))))
((* (Byte *) PBMSource Size-3)) << 8)
((* (Byte *) PBMSource Size-2)) << 16)
((* (Byte *) PBMSource Size-1)) << 24);
ISHELL_FREERESDATA (MJ-> A.M_Pishell, PBMSource);
BUF = (Byte *) Malloc (L);
Iunzipastream_SetStream (MJ-> Piunzipastream, (iastream *) MJ-> PMemStream);
NTMP = IUNZIPASTREAM_READ (MJ-> Piunzipastream, (void *) BUF, L);
IF (NTMP> 0)
{
WHILE (NTMP { NTMP = IUNZIPASTREAM_READ (MJ-> PiunziPastream, (void *) (BYTE *) (BUF NTMP), L-NTMP) NTMP;} PDATABYTES = (BYTE *) (BUF); BMP = ConvertBMP (PDataBytes, & imageInfo, & bval); * w = imageInfo.cx; * h = imageInfo.cy; Free (BUF); Return BMP; } ELSE IF ((NTMP == aee_stream_wouldblock) || (NTMP == 0))) { Free (BUF); Return NULL; } Return NULL; } Because it is very late, some details rely on everyone. Of course, big data files can also be used (including MIDI, WAV, etc.), but not, if you add a picture type, if you set a picture type, if you have a picture, if it is. BMP. Below is the code for solving the data file: Void * unzipex (MJ * MJ, Char * Res_file, uint16 id, uint32 * xsize) { UINT32 NTMP, SIZE, L; BYTE * BUF, * TMPBUF; Void * pbmsource = null; BYTE * PDATABYTES; Boolean Bval = True; IF (null == (pbmsource = ishell_loadresdataex (mj-> a.m_pishell, res_file, ID, RESTYPE_IMAGE, NULL, & Size)))))) { Return NULL; } TMPBUF = (Byte *) Malloc (size - * ((Byte *)))); Memcpy (TMPBUF, (Byte *) PBMSource * (PBMSource), size - * ((Byte *))))); IMEMASTREAM_SET (MJ-> Pmemstream, TmpBuf, Size - * ((Byte *) (PBMSource), 0, FALSE l = (* (Byte *) PBMSource Size-4)))) ((* (Byte *) PBMSource Size-3)) << 8) ((* (Byte *) PBMSource Size-2)) << 16) ((* (Byte *) PBMSource Size-1)) << 24); ISHELL_FREERESDATA (MJ-> A.M_Pishell, PBMSource); BUF = (Byte *) Malloc (L); Iunzipastream_SetStream (MJ-> Piunzipastream, (iastream *) MJ-> PMemStream); NTMP = IUNZIPASTREAM_READ (MJ-> Piunzipastream, (void *) BUF, L); IF (NTMP> 0) { // * xsize = NTMP; WHILE (NTMP { NTMP = IUNZIPASTREAM_READ (MJ-> PiunziPastream, (void *) (BYTE *) (BUF NTMP), L-NTMP) NTMP; } * xsize = l> NTMP? NTMP: L; pDataBytes = (BYTE *) (BUF); Return BUF; } ELSE IF ((NTMP == aee_stream_wouldblock) || (NTMP == 0))) { Free (BUF); Return NULL; } Return NULL; } These two functions I tested on multiple models such as Geners 6260, the speed is good, no slow feeling. The compression ratio of Gzip is close to PNG because the compression algorithm of the PNG is similar to Gzip. Gzip, big house can be found with Google search, if Cygwin is installed, it can be used directly (did not think of gzip.exe, I have been silly with Gzip in Cygwin)