From: ShadowFlare Date: Sun, 10 Sep 2006 05:29:39 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://sfsrealm.hopto.org/projects/?a=commitdiff_plain;h=03269fee39ef66bca887d4be10b93ab6995a12a4;p=grpapi.git --- diff --git a/grpapi/grpapi.cpp b/grpapi/grpapi.cpp index 6c1e737..7cc25b0 100644 --- a/grpapi/grpapi.cpp +++ b/grpapi/grpapi.cpp @@ -439,7 +439,7 @@ void __inline SetPix(HDC hDC, int X, int Y, COLORREF clrColor, DWORD *dwPalette, MySetPixel(hDC,X,Y,clrColor); } -HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, DWORD *nGrpSize) +HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, BOOL bNoCompress, DWORD *nGrpSize) { GRPHEADER GrpHeader; FRAMEHEADER *lpFrameHeaders; @@ -496,15 +496,20 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa lpFrameHeaders[i].Width = x2 - x1 + 1; lpFrameHeaders[i].Height = y2 - y1 + 1; - EncodeFrameData(lpImageData, i, &GrpHeader, &lpFrameHeaders[i], &lpFrameData[i]); + if (!bNoCompress) { + EncodeFrameData(lpImageData, i, &GrpHeader, &lpFrameHeaders[i], &lpFrameData[i]); - y = lpFrameHeaders[i].Height; - if (y > 0) { - y--; - nLastOffset = lpFrameHeaders[i].Offset + lpFrameData[i].lpRowOffsets[y] + lpFrameData[i].lpRowSizes[y]; + y = lpFrameHeaders[i].Height; + if (y > 0) { + y--; + nLastOffset = lpFrameHeaders[i].Offset + lpFrameData[i].lpRowOffsets[y] + lpFrameData[i].lpRowSizes[y]; + } + else { + nLastOffset = lpFrameHeaders[i].Offset; + } } else { - nLastOffset = lpFrameHeaders[i].Offset; + nLastOffset = lpFrameHeaders[i].Offset + lpFrameHeaders[i].Width * lpFrameHeaders[i].Height; } } @@ -516,18 +521,28 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa for (i = 0; i < nFrames; i++) { if (lpFrameData[i].lpRowOffsets) { - memcpy(lpGrpData + lpFrameHeaders[i].Offset, lpFrameData[i].lpRowOffsets, lpFrameHeaders[i].Height * sizeof(WORD)); + if (!bNoCompress) { + memcpy(lpGrpData + lpFrameHeaders[i].Offset, lpFrameData[i].lpRowOffsets, lpFrameHeaders[i].Height * sizeof(WORD)); - for (y = 0; y < lpFrameHeaders[i].Height; y++) { - if (lpFrameData[i].lpRowData[y]) { - memcpy(lpGrpData + lpFrameHeaders[i].Offset + lpFrameData[i].lpRowOffsets[y], lpFrameData[i].lpRowData[y], lpFrameData[i].lpRowSizes[y]); - free(lpFrameData[i].lpRowData[y]); + for (y = 0; y < lpFrameHeaders[i].Height; y++) { + if (lpFrameData[i].lpRowData[y]) { + memcpy(lpGrpData + lpFrameHeaders[i].Offset + lpFrameData[i].lpRowOffsets[y], lpFrameData[i].lpRowData[y], lpFrameData[i].lpRowSizes[y]); + free(lpFrameData[i].lpRowData[y]); + } } - } - free(lpFrameData[i].lpRowOffsets); - free(lpFrameData[i].lpRowSizes); - free(lpFrameData[i].lpRowData); + free(lpFrameData[i].lpRowOffsets); + free(lpFrameData[i].lpRowSizes); + free(lpFrameData[i].lpRowData); + } + else { + for (y = 0; y < lpFrameHeaders[i].Height; y++) { + for (x = 0; x < lpFrameHeaders[i].Width; x++) { + lpGrpData[lpFrameHeaders[i].Offset + y * lpFrameHeaders[i].Width + x] = + lpImageData[i * wMaxWidth * wMaxHeight + (lpFrameHeaders[i].Top + y) * wMaxWidth + lpFrameHeaders[i].Left + x]; + } + } + } } } @@ -553,7 +568,7 @@ void EncodeFrameData(signed short *lpImageData, WORD nFrame, GRPHEADER *lpGrpHea i = nFrame * lpGrpHeader->wMaxWidth * lpGrpHeader->wMaxHeight + (lpFrameHeader->Top + y) * lpGrpHeader->wMaxWidth; /* Fails verification when using this. Bug in encoder or decoder? Doesn't provide much benefit. - // Search for duplicate rows + // Search for duplicate rows (experimental) for (x = 0; x < y; x++) { j = nFrame * lpGrpHeader->wMaxWidth * lpGrpHeader->wMaxHeight + (lpFrameHeader->Top + x) * lpGrpHeader->wMaxWidth; if (memcmp(&lpImageData[i+lpFrameHeader->Left], diff --git a/grpapi/grpapi.h b/grpapi/grpapi.h index 73070c8..bfa6864 100644 --- a/grpapi/grpapi.h +++ b/grpapi/grpapi.h @@ -63,7 +63,7 @@ BOOL GRPAPI WINAPI DestroyGrp(HANDLE hGrp); BOOL GRPAPI WINAPI DrawGrp(HANDLE hGrp, HDC hdcDest, int nXDest, int nYDest, WORD nFrame, DWORD *dwPalette, DWORD dwFlags, DWORD dwAlpha); BOOL GRPAPI WINAPI GetGrpInfo(HANDLE hGrp, GRPHEADER *GrpInfo); -HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, DWORD *nGrpSize); +HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, BOOL bNoCompress, DWORD *nGrpSize); typedef COLORREF (WINAPI* GETPIXELPROC)( HDC hDC, // same value as hdcDest from DrawGrp, diff --git a/grpapi/grpapi_no-lib.h b/grpapi/grpapi_no-lib.h index 190beb5..2af7eec 100644 --- a/grpapi/grpapi_no-lib.h +++ b/grpapi/grpapi_no-lib.h @@ -66,7 +66,7 @@ extern funcDestroyGrp DestroyGrp; extern funcDrawGrp DrawGrp; extern funcGetGrpInfo GetGrpInfo; -typedef HANDLE (WINAPI* funcCreateGrp)(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, DWORD *nGrpSize); +typedef HANDLE (WINAPI* funcCreateGrp)(signed short *lpImageData, WORD nFrames, WORD wMaxWidth, WORD wMaxHeight, BOOL bNoCompress, DWORD *nGrpSize); extern funcCreateGrp CreateGrp; typedef COLORREF (WINAPI* GETPIXELPROC)(