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/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp
--- a/drawgrp/drawgrp.cpp
+++ b/drawgrp/drawgrp.cpp
// drawgrp.cpp : Defines the entry point for the console application.\r
//\r
\r
+#define _CRT_RAND_S\r
+#include <stdlib.h>\r
#include "stdafx.h"\r
\r
\r
struct BufferInfo {\r
WORD nWidth;\r
WORD nHeight;\r
- LPDWORD pBuffer;\r
+ signed short *pBuffer;\r
+ WORD nFrame;\r
};\r
\r
COLORREF WINAPI ReadPixelFromBuffer(BufferInfo *pBI, int X, int Y)\r
{\r
- return pBI->pBuffer[(Y * pBI->nWidth) + X];\r
+ if (pBI->nFrame == 0xFFFF)\r
+ return pBI->pBuffer[(Y * pBI->nWidth) + X];\r
+ else\r
+ return pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X];\r
}\r
\r
void WINAPI WritePixelToBuffer(BufferInfo *pBI, int X, int Y, COLORREF clrColor)\r
{\r
- pBI->pBuffer[(Y * pBI->nWidth) + X] = clrColor;\r
+ if (pBI->nFrame == 0xFFFF)\r
+ pBI->pBuffer[(Y * pBI->nWidth) + X] = (signed short)clrColor;\r
+ else\r
+ pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X] = (signed short)clrColor;\r
}\r
\r
int main(int argc, char* argv[])\r
memcpy(buffer,"Patch_rt.mpq",13);\r
SFileOpenArchive(buffer,3000,0,&hMPQ3);\r
}\r
- SetFunctionGetPixel((GETPIXELPROC)ReadPixelFromBuffer);\r
- SetFunctionSetPixel((SETPIXELPROC)WritePixelToBuffer);\r
BufferInfo BI;\r
LoadPalette("tileset\\Jungle.wpe",dwPalette);\r
- HANDLE hGrp;\r
+ HANDLE hGrp, hGrp2;\r
if (argc>1)\r
hGrp = LoadGrp(argv[1]);\r
else\r
if (GetGrpInfo(hGrp,&GrpInfo)==0) {GrpInfo.nFrames=0;GrpInfo.wMaxWidth=0;GrpInfo.wMaxHeight=0;}\r
BI.nWidth = GrpInfo.wMaxWidth;\r
BI.nHeight = GrpInfo.wMaxHeight;\r
- BI.pBuffer = (DWORD *)malloc(BI.nWidth * BI.nHeight * sizeof(DWORD));\r
+ BI.pBuffer = (signed short *)malloc(GrpInfo.nFrames * BI.nWidth * BI.nHeight * sizeof(short));\r
WORD i,x,y;\r
- DWORD j;\r
- for (i = 0; i < BI.nWidth * BI.nHeight; i++)\r
- BI.pBuffer[i] = 0xFFFFFFFF;\r
+ DWORD j, nGrpSize;\r
+ unsigned int u,v;\r
+ memset(BI.pBuffer, 0xFF, GrpInfo.nFrames * BI.nWidth * BI.nHeight * sizeof(short));\r
//for (DWORD j=0;j<16;j++){\r
/*for (WORD i=0;i<GrpInfo.nFrames;i++) {\r
DrawGrp(hGrp,hDC,0,0,i,dwPalette,ALPHA_BLEND,0x401020);\r
}*/\r
- COLORREF clrPixel;\r
+ signed short clrPixel;\r
RECT rect;\r
- for (i=13;i<400;i+=17) {\r
+ for (i=0;i<GrpInfo.nFrames;i++) {\r
+ for (j=0;j<8;j++)\r
+ {\r
+ rand_s(&u);\r
+ rand_s(&v);\r
+ u = u % 800;\r
+ v = v % 600;\r
+ //DrawGrp(hGrp,hDC,u,v,i,dwPalette,ALPHA_BLEND,0x404040);\r
+ }\r
+ }\r
+ SetFunctionGetPixel((GETPIXELPROC)ReadPixelFromBuffer);\r
+ SetFunctionSetPixel((SETPIXELPROC)WritePixelToBuffer);\r
+ for (i=0;i<GrpInfo.nFrames;i++) {\r
+ BI.nFrame = i;\r
+ DrawGrp(hGrp,(HDC)&BI,0,0,i,0,USE_INDEX,0);\r
+ }\r
+ hGrp2 = hGrp;\r
+ hGrp = CreateGrp(BI.pBuffer, GrpInfo.nFrames, GrpInfo.wMaxWidth, GrpInfo.wMaxHeight, &nGrpSize);\r
+ BI.nFrame = 0xFFFF;\r
+ for (i=13;i<14;i+=17) {\r
rect.left = rect.top = i;\r
rect.right = rect.left + BI.nWidth;\r
rect.bottom = rect.top + BI.nHeight;\r
for (x = 0; x < BI.nWidth * BI.nHeight; x++)\r
- BI.pBuffer[x] = 0xFFFFFFFF;\r
- for (j=0;j<32;j++) {\r
+ BI.pBuffer[x] = -1;\r
+ for (j=0;j<(32 * 25);j++) {\r
// DrawGrp(hGrp,(HDC)&BI,i,0,i % (17*8),dwPalette,ALPHA_BLEND,0x401020);\r
- DrawGrp(hGrp,(HDC)&BI,0,0,i % (17*8),dwPalette,USE_INDEX,0x401020);\r
+ DrawGrp(hGrp2,(HDC)&BI,0,0,i % (17*8),0,USE_INDEX,0x401020);\r
+ u = memcmp(BI.pBuffer, &BI.pBuffer[(i % (17*8)) * BI.nWidth * BI.nHeight], BI.nWidth * BI.nHeight * sizeof(short));\r
+ DrawGrp(hGrp,(HDC)&BI,0,0,i % (17*8),0,USE_INDEX,0x401020);\r
+ u = memcmp(BI.pBuffer, &BI.pBuffer[(i % (17*8)) * BI.nWidth * BI.nHeight], BI.nWidth * BI.nHeight * sizeof(short));\r
for (x = 0; x < BI.nWidth; x++)\r
for (y = 0; y < BI.nHeight; y++) {\r
clrPixel = BI.pBuffer[(y * BI.nWidth) + x];\r
- if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, i + x, i + y, dwPalette[clrPixel]);\r
+ if (clrPixel != -1) SetPixelV(hDC, i + x, i + y, dwPalette[clrPixel]);\r
}\r
}\r
+ if (u) {\r
+ MessageBox(0, "Output of re-encoded graphic does not match original!", 0, 0);\r
+ break;\r
+ }\r
FillRect(hDC, &rect, (HBRUSH) (COLOR_WINDOW+1));\r
}\r
for (i=4;i<400;i+=17) {\r
rect.right = rect.left + BI.nWidth;\r
rect.bottom = rect.top + BI.nHeight;\r
for (x = 0; x < BI.nWidth * BI.nHeight; x++)\r
- BI.pBuffer[x] = 0xFFFFFFFF;\r
+ BI.pBuffer[x] = -1;\r
for (j=0;j<32;j++) {\r
// DrawGrp(hGrp,(HDC)&BI,400-i,0,i % (17*8),dwPalette,HORIZONTAL_FLIP|ALPHA_BLEND,0x401020);\r
- DrawGrp(hGrp,(HDC)&BI,0,0,i % (17*8),dwPalette,HORIZONTAL_FLIP|USE_INDEX,0x401020);\r
+ DrawGrp(hGrp,(HDC)&BI,0,0,i % (17*8),0,HORIZONTAL_FLIP|USE_INDEX,0x401020);\r
for (x = 0; x < BI.nWidth; x++)\r
for (y = 0; y < BI.nHeight; y++) {\r
clrPixel = BI.pBuffer[(y * BI.nWidth) + x];\r
- if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, 400-i + x, 400-i + y, dwPalette[clrPixel]);\r
+ if (clrPixel != -1) SetPixelV(hDC, 400-i + x, 400-i + y, dwPalette[clrPixel]);\r
}\r
}\r
FillRect(hDC, &rect, (HBRUSH) (COLOR_WINDOW+1));\r
for (i = 0; i < BI.nWidth; i++)\r
for (j = 0; j < BI.nHeight; j++) {\r
clrPixel = BI.pBuffer[(j * BI.nWidth) + i];\r
- if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, 400 + i, 300 + j, dwPalette[clrPixel]);\r
+ if (clrPixel != -1) SetPixelV(hDC, 400 + i, 300 + j, dwPalette[clrPixel]);\r
}\r
//}\r
ReleaseDC(0,hDC);\r
free(BI.pBuffer);\r
DestroyGrp(hGrp);\r
+ DestroyGrp(hGrp2);\r
if (SFileCloseArchive!=0) {\r
if (hMPQ3!=0) SFileCloseArchive(hMPQ3);\r
if (hMPQ2!=0) SFileCloseArchive(hMPQ2);\r
|