Current News
Archived News
Search News
Discussion Forum


Old Forum
Install Programs More Downloads...
Troubleshooting
Source Code
Format Specs.
Misc. Information
Non-SF Stuff
Links




index 6e6b3ff..b002e12 100644 (file)
@@ -38,14 +38,15 @@ typedef struct {
        WORD *lpRowOffsets;\r
        WORD *lpRowSizes;\r
        LPBYTE *lpRowData;\r
+       DWORD Size;\r
 } FRAMEDATA;\r
 \r
 GETPIXELPROC MyGetPixel = GetPixel;\r
 SETPIXELPROC MySetPixel = (SETPIXELPROC)SetPixelV;\r
 \r
 void __inline SetPix(HDC hDC, int X, int Y, COLORREF clrColor, DWORD *dwPalette, DWORD dwFlags, DWORD dwAlpha);\r
-void EncodeFrameData(signed short *lpImageData, WORD nFrame, GRPHEADER *lpGrpHeader, FRAMEHEADER *lpFrameHeader, FRAMEDATA *lpFrameData);\r
-BOOL VerifyRow(signed short *lpRawRow, int nWidth, LPBYTE lpEncRow, int nSize);\r
+void EncodeFrameData(signed short *lpImageData, WORD nFrame, GRPHEADER *lpGrpHeader, FRAMEHEADER *lpFrameHeader, FRAMEDATA *lpFrameData, BOOL bNoCompress);\r
+BOOL VerifyRow(signed short *lpRawRow, int nWidth, LPBYTE lpEncRow, int nSize, BOOL bNoCompress);\r
 \r
 extern HINSTANCE hStorm;\r
 \r
@@ -223,24 +224,33 @@ BOOL GRPAPI WINAPI DrawGrp(HANDLE hGrp, HDC hdcDest, int nXDest, int nYDest, WOR
        BYTE *GrpRaw = (BYTE *)GrpOffsets;\r
        BYTE *RowData;\r
        WORD x,ofs;\r
-       DWORD y;\r
+       DWORD y, nMaxOffset = 0;\r
        WORD i;\r
-       int j;\r
-       if (nFrame + 1 < GrpFile->nFrames) {\r
-               for (i = 0; i + 1 < GrpFile->nFrames; i++) {\r
-                       j = GrpFrames[i].Offset - GrpFrame->Offset;\r
-                       if (j > 0 && j < FrameSize)\r
-                               FrameSize = j;\r
-               }\r
+       int j, nFirstNonBlankFrame = 0;\r
+       for (i = 0; i < GrpFile->nFrames; i++) {\r
+               j = GrpFrames[i].Offset - GrpFrame->Offset;\r
+               if (j > 0 && j < FrameSize)\r
+                       FrameSize = j;\r
+               if (GrpFrames[i].Offset > nMaxOffset)\r
+                       nMaxOffset = GrpFrames[i].Offset;\r
        }\r
        if (FrameSize == 0xFFFFFF || FrameSize == GrpFrame->Width * GrpFrame->Height) {\r
                FrameSize = 0xFFFFFF;\r
-               for (i = 0; i + 1 < GrpFile->nFrames; i++) {\r
-                       j = GrpFrames[i].Offset - GrpFrames[0].Offset;\r
+               for (i = 0; i < GrpFile->nFrames; i++) {\r
+                       if (GrpFrames[i].Width != 0 && GrpFrames[i].Height != 0 && GrpFrames[i].Offset != GrpFrame->Offset && GrpFrames[i].Offset != nMaxOffset) {\r
+                               nFirstNonBlankFrame = i;\r
+                               break;\r
+                       }\r
+               }\r
+               if (i == GrpFile->nFrames)\r
+                       nFirstNonBlankFrame = nFrame;\r
+\r
+               for (i = 0; i < GrpFile->nFrames; i++) {\r
+                       j = GrpFrames[i].Offset - GrpFrames[nFirstNonBlankFrame].Offset;\r
                        if (j > 0 && j < FrameSize)\r
                                FrameSize = j;\r
                }\r
-               if (FrameSize == GrpFrames[0].Width * GrpFrames[0].Height)\r
+               if (FrameSize == GrpFrames[nFirstNonBlankFrame].Width * GrpFrames[nFirstNonBlankFrame].Height)\r
                        FrameSize = GrpFrame->Width * GrpFrame->Height;\r
        }\r
        if (!(dwFlags&HORIZONTAL_FLIP) && !(dwFlags&VERTICAL_FLIP)) {\r
@@ -401,6 +411,19 @@ BOOL GRPAPI WINAPI GetGrpInfo(HANDLE hGrp, GRPHEADER *GrpInfo)
        return TRUE;\r
 }\r
 \r
+BOOL GRPAPI WINAPI GetGrpFrameInfo(HANDLE hGrp, WORD nFrame, DWORD *nLeft, DWORD *nTop, DWORD *nWidth, DWORD *nHeight)\r
+{\r
+       if (!hGrp || hGrp==INVALID_HANDLE_VALUE) return FALSE;\r
+       FRAMEHEADER *GrpFrame = &((FRAMEHEADER *)(((char *)hGrp)+6))[nFrame];\r
+\r
+       if (nLeft) *nLeft = GrpFrame->Left;\r
+       if (nTop) *nTop = GrpFrame->Top;\r
+       if (nWidth) *nWidth = GrpFrame->Width;\r
+       if (nHeight) *nHeight = GrpFrame->Height;\r
+\r
+       return TRUE;\r
+}\r
+\r
 void GRPAPI WINAPI SetFunctionGetPixel(GETPIXELPROC lpGetPixelProc)\r
 {\r
        if (!lpGetPixelProc)\r
@@ -476,26 +499,7 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa
        nLastOffset = sizeof(GRPHEADER) + nFrames * sizeof(FRAMEHEADER);\r
 \r
        for (i = 0; i < nFrames; i++) {\r
-               // Search for duplicate frames\r
-               for (j = 0; j < i; j++) {\r
-                       if (memcmp(&lpImageData[i * wMaxWidth * wMaxHeight],\r
-                                  &lpImageData[j * wMaxWidth * wMaxHeight],\r
-                                          wMaxWidth * wMaxHeight * sizeof(short)) == 0)\r
-                               break;\r
-               }\r
-\r
-               if (j < i) {\r
-                       memcpy(&lpFrameHeaders[i], &lpFrameHeaders[j], sizeof(FRAMEHEADER));\r
-                       lpFrameData[i].lpRowOffsets = 0;\r
-                       continue;\r
-               }\r
-\r
-               if (i == 0) {\r
-                       lpFrameHeaders[i].Offset = sizeof(GRPHEADER) + nFrames * sizeof(FRAMEHEADER);\r
-               }\r
-               else {\r
-                       lpFrameHeaders[i].Offset = nLastOffset;\r
-               }\r
+               lpFrameHeaders[i].Offset = nLastOffset;\r
 \r
                // Scan frame to find dimensions of used part\r
                x1 = y1 = 0x10000;\r
@@ -521,21 +525,38 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa
                lpFrameHeaders[i].Width = x2;\r
                lpFrameHeaders[i].Height = y2;\r
 \r
-               if (!bNoCompress) {\r
-                       EncodeFrameData(lpImageData, i, &GrpHeader, &lpFrameHeaders[i], &lpFrameData[i]);\r
+               // Search for duplicate frames\r
+               for (j = 0; j < i; j++) {\r
+                       if (lpFrameData[j].lpRowOffsets && lpFrameHeaders[i].Width == lpFrameHeaders[j].Width && lpFrameHeaders[i].Height == lpFrameHeaders[j].Height) {\r
+                               y1 = i * wMaxWidth * wMaxHeight + lpFrameHeaders[i].Top * wMaxWidth + lpFrameHeaders[i].Left;\r
+                               y2 = j * wMaxWidth * wMaxHeight + lpFrameHeaders[j].Top * wMaxWidth + lpFrameHeaders[j].Left;\r
 \r
-                       y = lpFrameHeaders[i].Height;\r
-                       if (y > 0) {\r
-                               y--;\r
-                               nLastOffset = lpFrameHeaders[i].Offset + lpFrameData[i].lpRowOffsets[y] + lpFrameData[i].lpRowSizes[y];\r
-                       }\r
-                       else {\r
-                               nLastOffset = lpFrameHeaders[i].Offset;\r
+                               for (y = 0; y < lpFrameHeaders[i].Height; y++) {\r
+                                       if (memcmp(&lpImageData[y1], &lpImageData[y2], lpFrameHeaders[i].Width * sizeof(short)) != 0)\r
+                                               break;\r
+\r
+                                       y1 += wMaxWidth;\r
+                                       y2 += wMaxWidth;\r
+                               }\r
+\r
+                               if (y == lpFrameHeaders[i].Height) {\r
+                                       break;\r
+                               }\r
                        }\r
                }\r
-               else {\r
-                       nLastOffset = lpFrameHeaders[i].Offset + lpFrameHeaders[i].Width * lpFrameHeaders[i].Height;\r
+\r
+               if (j < i) {\r
+                       // Duplicate frame found, set offset and flag as duplicate\r
+                       lpFrameHeaders[i].Offset = lpFrameHeaders[j].Offset;\r
+                       lpFrameData[i].lpRowOffsets = 0;\r
+                       lpFrameData[i].lpRowSizes = 0;\r
+                       lpFrameData[i].lpRowData = 0;\r
+                       lpFrameData[i].Size = 0;\r
+                       continue;\r
                }\r
+\r
+               EncodeFrameData(lpImageData, i, &GrpHeader, &lpFrameHeaders[i], &lpFrameData[i], bNoCompress);\r
+               nLastOffset = lpFrameHeaders[i].Offset + lpFrameData[i].Size;\r
        }\r
 \r
        lpGrpData = (LPBYTE)malloc(nLastOffset);\r
@@ -546,28 +567,19 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa
 \r
        for (i = 0; i < nFrames; i++) {\r
                if (lpFrameData[i].lpRowOffsets) {\r
-                       if (!bNoCompress) {\r
+                       if (!bNoCompress)\r
                                memcpy(lpGrpData + lpFrameHeaders[i].Offset, lpFrameData[i].lpRowOffsets, lpFrameHeaders[i].Height * sizeof(WORD));\r
 \r
-                               for (y = 0; y < lpFrameHeaders[i].Height; y++) {\r
-                                       if (lpFrameData[i].lpRowData[y]) {\r
-                                               memcpy(lpGrpData + lpFrameHeaders[i].Offset + lpFrameData[i].lpRowOffsets[y], lpFrameData[i].lpRowData[y], lpFrameData[i].lpRowSizes[y]);\r
-                                               free(lpFrameData[i].lpRowData[y]);\r
-                                       }\r
-                               }\r
-\r
-                               free(lpFrameData[i].lpRowOffsets);\r
-                               free(lpFrameData[i].lpRowSizes);\r
-                               free(lpFrameData[i].lpRowData);\r
-                       }\r
-                       else {\r
-                               for (y = 0; y < lpFrameHeaders[i].Height; y++) {\r
-                                       for (x = 0; x < lpFrameHeaders[i].Width; x++) {\r
-                                               lpGrpData[lpFrameHeaders[i].Offset + y * lpFrameHeaders[i].Width + x] =\r
-                                                       (BYTE)lpImageData[i * wMaxWidth * wMaxHeight + (lpFrameHeaders[i].Top + y) * wMaxWidth + lpFrameHeaders[i].Left + x];\r
-                                       }\r
+                       for (y = 0; y < lpFrameHeaders[i].Height; y++) {\r
+                               if (lpFrameData[i].lpRowData[y]) {\r
+                                       memcpy(lpGrpData + lpFrameHeaders[i].Offset + lpFrameData[i].lpRowOffsets[y], lpFrameData[i].lpRowData[y], lpFrameData[i].lpRowSizes[y]);\r
+                                       free(lpFrameData[i].lpRowData[y]);\r
                                }\r
                        }\r
+\r
+                       free(lpFrameData[i].lpRowOffsets);\r
+                       free(lpFrameData[i].lpRowSizes);\r
+                       free(lpFrameData[i].lpRowData);\r
                }\r
        }\r
 \r
@@ -578,119 +590,122 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa
        return (HANDLE)lpGrpData;\r
 }\r
 \r
-void EncodeFrameData(signed short *lpImageData, WORD nFrame, GRPHEADER *lpGrpHeader, FRAMEHEADER *lpFrameHeader, FRAMEDATA *lpFrameData)\r
+void EncodeFrameData(signed short *lpImageData, WORD nFrame, GRPHEADER *lpGrpHeader, FRAMEHEADER *lpFrameHeader, FRAMEDATA *lpFrameData, BOOL bNoCompress)\r
 {\r
-       int x, y, i, nBufPos, nRepeat;\r
+       int x, y, i, j, nBufPos, nRepeat;\r
        LPBYTE lpRowBuf;\r
-       WORD nLastOffset;\r
+       WORD nLastOffset = 0;\r
 \r
        lpFrameData->lpRowOffsets = (WORD *)malloc(lpFrameHeader->Height * sizeof(WORD));\r
        lpFrameData->lpRowSizes = (WORD *)malloc(lpFrameHeader->Height * sizeof(WORD));\r
        lpFrameData->lpRowData = (LPBYTE *)malloc(lpFrameHeader->Height * sizeof(LPBYTE));\r
        lpRowBuf = (LPBYTE)malloc(lpFrameHeader->Width * 2);\r
-       nLastOffset = lpFrameHeader->Height * sizeof(WORD);\r
+\r
+       if (!bNoCompress)\r
+               nLastOffset = lpFrameHeader->Height * sizeof(WORD);\r
 \r
        for (y = 0; y < lpFrameHeader->Height; y++) {\r
                i = nFrame * lpGrpHeader->wMaxWidth * lpGrpHeader->wMaxHeight + (lpFrameHeader->Top + y) * lpGrpHeader->wMaxWidth;\r
 \r
-               /* Fails verification when using this.  Bug in encoder or decoder?  Doesn't provide much benefit.\r
-               // Search for duplicate rows (experimental)\r
-               for (x = 0; x < y; x++) {\r
-                       j = nFrame * lpGrpHeader->wMaxWidth * lpGrpHeader->wMaxHeight + (lpFrameHeader->Top + x) * lpGrpHeader->wMaxWidth;\r
-                       if (memcmp(&lpImageData[i+lpFrameHeader->Left],\r
-                                  &lpImageData[j+lpFrameHeader->Left],\r
-                                  lpGrpHeader->wMaxWidth * sizeof(short)) == 0)\r
-                               break;\r
-               }\r
+               if (!bNoCompress) {\r
+                       // Search for duplicate rows\r
+                       for (x = 0; x < y; x++) {\r
+                               j = nFrame * lpGrpHeader->wMaxWidth * lpGrpHeader->wMaxHeight + (lpFrameHeader->Top + x) * lpGrpHeader->wMaxWidth;\r
+                               if (memcmp(&lpImageData[i+lpFrameHeader->Left],\r
+                                                  &lpImageData[j+lpFrameHeader->Left],\r
+                                                  lpGrpHeader->wMaxWidth * sizeof(short)) == 0)\r
+                                       break;\r
+                       }\r
 \r
-               if (x < y) {\r
-                       lpFrameData->lpRowOffsets[y] = lpFrameData->lpRowOffsets[x];\r
-                       lpFrameData->lpRowSizes[y] = 0;\r
-                       lpFrameData->lpRowData[y] = 0;\r
+                       if (x < y) {\r
+                               lpFrameData->lpRowOffsets[y] = lpFrameData->lpRowOffsets[x];\r
+                               lpFrameData->lpRowSizes[y] = 0;\r
+                               lpFrameData->lpRowData[y] = 0;\r
 \r
 #ifdef _DEBUG\r
-                       if (!VerifyRow(&lpImageData[i+lpFrameHeader->Left], lpFrameHeader->Width, lpFrameData->lpRowData[x], lpFrameData->lpRowSizes[x])) {\r
-                               nBufPos = nBufPos;\r
-                       }\r
+                               if (!VerifyRow(&lpImageData[i+lpFrameHeader->Left], lpFrameHeader->Width, lpFrameData->lpRowData[x], lpFrameData->lpRowSizes[x], bNoCompress)) {\r
+                                       nBufPos = nBufPos;\r
+                               }\r
 #endif\r
 \r
-                       continue;\r
+                               continue;\r
+                       }\r
                }\r
-               */\r
 \r
                nBufPos = 0;\r
                if (lpFrameHeader->Width > 0) {\r
                        for (x = lpFrameHeader->Left; x < lpFrameHeader->Left + lpFrameHeader->Width; x++) {\r
-                               if (x < lpFrameHeader->Left + lpFrameHeader->Width - 1) {\r
-                                       if (lpImageData[i+x] < 0) {\r
-                                               lpRowBuf[nBufPos] = 0x80;\r
-                                               for (; lpImageData[i+x] < 0 && x < lpFrameHeader->Left + lpFrameHeader->Width && lpRowBuf[nBufPos] < 0xFF; x++) {\r
-                                                       lpRowBuf[nBufPos]++;\r
+                               if (!bNoCompress) {\r
+                                       if (x < lpFrameHeader->Left + lpFrameHeader->Width - 1) {\r
+                                               if (lpImageData[i+x] < 0) {\r
+                                                       lpRowBuf[nBufPos] = 0x80;\r
+                                                       for (; lpImageData[i+x] < 0 && x < lpFrameHeader->Left + lpFrameHeader->Width && lpRowBuf[nBufPos] < 0xFF; x++) {\r
+                                                               lpRowBuf[nBufPos]++;\r
+                                                       }\r
+                                                       x--;\r
+                                                       if (nLastOffset + nBufPos + 1 <= 0xFFFF)\r
+                                                               nBufPos++;\r
+                                                       continue;\r
                                                }\r
-                                               x--;\r
-                                               if (nLastOffset + nBufPos + 1 <= 0xFFFF)\r
-                                                       nBufPos++;\r
-                                               continue;\r
-                                       }\r
 \r
-                                       // Count repeating pixels, nRepeat = number of pixels - 1, ignore if there are less than 4 duplicates\r
-                                       for (nRepeat = 0; lpImageData[i+x+nRepeat] == lpImageData[i+x+nRepeat+1] && x+nRepeat < lpFrameHeader->Left + lpFrameHeader->Width - 1 && nRepeat < 0x3E; nRepeat++) {}\r
+                                               // Count repeating pixels, nRepeat = number of pixels - 1, ignore if there are less than 4 duplicates\r
+                                               for (nRepeat = 0; lpImageData[i+x+nRepeat] == lpImageData[i+x+nRepeat+1] && x+nRepeat < lpFrameHeader->Left + lpFrameHeader->Width - 1 && nRepeat < 0x3E; nRepeat++) {}\r
 \r
-                                       if (nRepeat > 2) {\r
-                                               lpRowBuf[nBufPos] = 0x41 + nRepeat;\r
-                                               lpRowBuf[nBufPos+1] = (BYTE)lpImageData[i+x];\r
-                                               x += nRepeat;\r
-                                               if (nLastOffset + nBufPos + 2 <= 0xFFFF)\r
-                                                       nBufPos += 2;\r
+                                               if (nRepeat > 2) {\r
+                                                       lpRowBuf[nBufPos] = 0x41 + nRepeat;\r
+                                                       lpRowBuf[nBufPos+1] = (BYTE)(lpImageData[i+x]);\r
+                                                       x += nRepeat;\r
+                                                       if (nLastOffset + nBufPos + 2 <= 0xFFFF)\r
+                                                               nBufPos += 2;\r
+                                               }\r
+                                               else {\r
+                                                       lpRowBuf[nBufPos] = 0;\r
+                                                       for (; lpImageData[i+x] >= 0 && x < lpFrameHeader->Left + lpFrameHeader->Width && lpRowBuf[nBufPos] < 0x3F; x++) {\r
+                                                               // Count repeating pixels, ignore if there are less than 4 duplicates\r
+                                                               for (nRepeat = 0; lpImageData[i+x+nRepeat] == lpImageData[i+x+nRepeat+1] && x+nRepeat < lpFrameHeader->Left + lpFrameHeader->Width - 1 && nRepeat < 3; nRepeat++) {}\r
+                                                               if (nRepeat > 2) break;\r
+\r
+                                                               lpRowBuf[nBufPos]++;\r
+                                                               lpRowBuf[nBufPos+lpRowBuf[nBufPos]] = (BYTE)(lpImageData[i+x]);\r
+                                                       }\r
+                                                       if (lpImageData[i+x] >= 0 && x == lpFrameHeader->Left + lpFrameHeader->Width - 1 && lpRowBuf[nBufPos] < 0x3F) {\r
+                                                               lpRowBuf[nBufPos]++;\r
+                                                               lpRowBuf[nBufPos+lpRowBuf[nBufPos]] = (BYTE)(lpImageData[i+x]);\r
+                                                       }\r
+                                                       x--;\r
+                                                       if (nLastOffset + nBufPos + 1 + lpRowBuf[nBufPos] <= 0xFFFF)\r
+                                                               nBufPos += 1 + lpRowBuf[nBufPos];\r
+                                               }\r
                                        }\r
                                        else {\r
-                                               lpRowBuf[nBufPos] = 0;\r
-                                               for (; lpImageData[i+x] >= 0 && x < lpFrameHeader->Left + lpFrameHeader->Width && lpRowBuf[nBufPos] < 0x3F; x++) {\r
-                                                       // Count repeating pixels, ignore if there are less than 4 duplicates\r
-                                                       for (nRepeat = 0; lpImageData[i+x+nRepeat] == lpImageData[i+x+nRepeat+1] && x+nRepeat < lpFrameHeader->Left + lpFrameHeader->Width - 1 && nRepeat < 3; nRepeat++) {}\r
-                                                       if (nRepeat > 2) break;\r
-\r
-                                                       lpRowBuf[nBufPos]++;\r
-                                                       lpRowBuf[nBufPos+lpRowBuf[nBufPos]] = (BYTE)lpImageData[i+x];\r
+                                               if (lpImageData[i+x] < 0) {\r
+                                                       lpRowBuf[nBufPos] = 0x81;\r
+                                                       if (nLastOffset + nBufPos + 1 <= 0xFFFF)\r
+                                                               nBufPos++;\r
                                                }\r
-                                               if (lpImageData[i+x] >= 0 && x == lpFrameHeader->Left + lpFrameHeader->Width - 1 && lpRowBuf[nBufPos] < 0x3F) {\r
-                                                       lpRowBuf[nBufPos]++;\r
-                                                       lpRowBuf[nBufPos+lpRowBuf[nBufPos]] = (BYTE)lpImageData[i+x];\r
+                                               else {\r
+                                                       lpRowBuf[nBufPos] = 1;\r
+                                                       lpRowBuf[nBufPos+1] = (BYTE)(lpImageData[i+x]);\r
+                                                       if (nLastOffset + nBufPos + 2 <= 0xFFFF)\r
+                                                               nBufPos += 2;\r
                                                }\r
-                                               x--;\r
-                                               if (nLastOffset + nBufPos + 1 + lpRowBuf[nBufPos] <= 0xFFFF)\r
-                                                       nBufPos += 1 + lpRowBuf[nBufPos];\r
                                        }\r
                                }\r
                                else {\r
-                                       if (lpImageData[i+x] < 0) {\r
-                                               lpRowBuf[nBufPos] = 0x81;\r
-                                               if (nLastOffset + nBufPos + 1 <= 0xFFFF)\r
-                                                       nBufPos++;\r
-                                       }\r
-                                       else {\r
-                                               lpRowBuf[nBufPos] = 1;\r
-                                               lpRowBuf[nBufPos+1] = (BYTE)lpImageData[i+x];\r
-                                               if (nLastOffset + nBufPos + 2 <= 0xFFFF)\r
-                                                       nBufPos += 2;\r
-                                       }\r
+                                       lpRowBuf[nBufPos] = (BYTE)(lpImageData[i+x]);\r
+                                       if (nLastOffset + nBufPos + 1 <= 0xFFFF)\r
+                                               nBufPos++;\r
                                }\r
                        }\r
                }\r
 \r
 #ifdef _DEBUG\r
-               if (!VerifyRow(&lpImageData[i+lpFrameHeader->Left], lpFrameHeader->Width, lpRowBuf, nBufPos)) {\r
+               if (!VerifyRow(&lpImageData[i+lpFrameHeader->Left], lpFrameHeader->Width, lpRowBuf, nBufPos, bNoCompress)) {\r
                        nBufPos = nBufPos;\r
                }\r
 #endif\r
 \r
-               if (y == 0) {\r
-                       lpFrameData->lpRowOffsets[y] = lpFrameHeader->Height * sizeof(WORD);\r
-               }\r
-               else {\r
-                       lpFrameData->lpRowOffsets[y] = nLastOffset;\r
-               }\r
-\r
+               lpFrameData->lpRowOffsets[y] = nLastOffset;\r
                nLastOffset = lpFrameData->lpRowOffsets[y] + nBufPos;\r
 \r
                lpFrameData->lpRowSizes[y] = nBufPos;\r
@@ -698,35 +713,44 @@ void EncodeFrameData(signed short *lpImageData, WORD nFrame, GRPHEADER *lpGrpHea
                memcpy(lpFrameData->lpRowData[y], lpRowBuf, nBufPos);\r
        }\r
 \r
+       lpFrameData->Size = nLastOffset;\r
+\r
        free(lpRowBuf);\r
 }\r
 \r
 #ifdef _DEBUG\r
-BOOL VerifyRow(signed short *lpRawRow, int nWidth, LPBYTE lpEncRow, int nSize)\r
+BOOL VerifyRow(signed short *lpRawRow, int nWidth, LPBYTE lpEncRow, int nSize, BOOL bNoCompress)\r
 {\r
        int i,x=0,ofs=0;\r
        while (x < nWidth && ofs < nSize) {\r
-               if (!(lpEncRow[ofs] & 0x80)) {\r
-                       if (!(lpEncRow[ofs] & 0x40)) {\r
-                               for (i=1;i<=lpEncRow[ofs] && x<nWidth;i++) {\r
-                                       if (lpEncRow[ofs+i] != (BYTE)lpRawRow[x]) return FALSE;\r
-                                       x++;\r
+               if (!bNoCompress) {\r
+                       if (!(lpEncRow[ofs] & 0x80)) {\r
+                               if (!(lpEncRow[ofs] & 0x40)) {\r
+                                       for (i=1;i<=lpEncRow[ofs] && x<nWidth;i++) {\r
+                                               if (lpEncRow[ofs+i] != (BYTE)lpRawRow[x]) return FALSE;\r
+                                               x++;\r
+                                       }\r
+                                       ofs+=lpEncRow[ofs]+1;\r
+                               }\r
+                               else {\r
+                                       for (i=0;i<lpEncRow[ofs]-64 && x<nWidth;i++) {\r
+                                               if (lpEncRow[ofs+1] != (BYTE)lpRawRow[x]) return FALSE;\r
+                                               x++;\r
+                                       }\r
+                                       ofs+=2;\r
                                }\r
-                               ofs+=lpEncRow[ofs]+1;\r
                        }\r
                        else {\r
-                               for (i=0;i<lpEncRow[ofs]-64 && x<nWidth;i++) {\r
-                                       if (lpEncRow[ofs+1] != (BYTE)lpRawRow[x]) return FALSE;\r
-                                       x++;\r
+                               for (i=0;i<lpEncRow[ofs]-128 && x<nWidth;i++) {\r
+                                       if (lpRawRow[x] >= 0) return FALSE;\r
                                }\r
-                               ofs+=2;\r
+                               x+=lpEncRow[ofs]-128;\r
+                               ofs++;\r
                        }\r
                }\r
                else {\r
-                       for (i=0;i<lpEncRow[ofs]-128 && x<nWidth;i++) {\r
-                               if (lpRawRow[x] >= 0) return FALSE;\r
-                       }\r
-                       x+=lpEncRow[ofs]-128;\r
+                       if (lpEncRow[ofs] != (BYTE)lpRawRow[x]) return FALSE;\r
+                       x++;\r
                        ofs++;\r
                }\r
        }\r