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 Small banner for links to this site: |
diff --git a/grpapi/grpapi.cpp b/grpapi/grpapi.cpp
--- a/grpapi/grpapi.cpp
+++ b/grpapi/grpapi.cpp
@@ -499,20 +499,6 @@ 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
lpFrameHeaders[i].Offset = nLastOffset;\r
\r
// Scan frame to find dimensions of used part\r
@@ -540,6 +526,47 @@ HANDLE GRPAPI WINAPI CreateGrp(signed short *lpImageData, WORD nFrames, WORD wMa
lpFrameHeaders[i].Height = y2;\r
\r
EncodeFrameData(lpImageData, i, &GrpHeader, &lpFrameHeaders[i], &lpFrameData[i], bNoCompress);\r
+\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 && lpFrameData[i].Size == lpFrameData[j].Size) {\r
+ for (y = 0; y < lpFrameHeaders[i].Height; y++) {\r
+ if (!lpFrameData[i].lpRowData[y] && !lpFrameData[j].lpRowData[y])\r
+ continue;\r
+\r
+ if ((!lpFrameData[i].lpRowData[y] && lpFrameData[j].lpRowData[y]) || (lpFrameData[i].lpRowData[y] && !lpFrameData[j].lpRowData[y]) || lpFrameData[i].lpRowSizes[y] != lpFrameData[j].lpRowSizes[y])\r
+ break;\r
+\r
+ if (memcmp(lpFrameData[i].lpRowData[y], lpFrameData[j].lpRowData[y], lpFrameData[i].lpRowSizes[y]) != 0)\r
+ break;\r
+ }\r
+\r
+ if (y == lpFrameHeaders[i].Height) {\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (j < i) {\r
+ // Duplicate frame found, free stored frame data and change offset\r
+ for (y = 0; y < lpFrameHeaders[i].Height; y++) {\r
+ if (lpFrameData[i].lpRowData[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
+ 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
nLastOffset = lpFrameHeaders[i].Offset + lpFrameData[i].Size;\r
}\r
\r
|