From: ShadowFlare Date: Wed, 29 Mar 2006 22:30:34 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://sfsrealm.hopto.org/projects/?a=commitdiff_plain;h=7f7b4247b021a783cbba059c344ddcdc1a80e58f;p=grpapi.git --- diff --git a/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp index 9adc351..4de2c4c 100644 --- a/drawgrp/drawgrp.cpp +++ b/drawgrp/drawgrp.cpp @@ -17,11 +17,29 @@ int main(int argc, char* argv[]) return RetVal; }*/ +struct BufferInfo { + WORD nWidth; + WORD nHeight; + LPDWORD pBuffer; +}; + +COLORREF WINAPI ReadPixelFromBuffer(BufferInfo *pBI, int X, int Y) +{ + return pBI->pBuffer[(Y * pBI->nWidth) + X]; +} + +void WINAPI WritePixelToBuffer(BufferInfo *pBI, int X, int Y, COLORREF clrColor) +{ + pBI->pBuffer[(Y * pBI->nWidth) + X] = clrColor; +} + int main(int argc, char* argv[]) { HANDLE hMPQ=0,hMPQ2=0,hMPQ3=0; DWORD *dwPalette = (DWORD *)_alloca(1024); memset(dwPalette,0,1024); + LoadStorm("SFMpq.dll"); + SetMpqDll("SFMpq.dll"); if (SFileOpenArchive!=0) { char *buffer = (char *)_alloca(13); memcpy(buffer,"StarDat.mpq",12); @@ -31,6 +49,9 @@ int main(int argc, char* argv[]) memcpy(buffer,"Patch_rt.mpq",13); SFileOpenArchive(buffer,3000,0,&hMPQ3); } + SetFunctionGetPixel((GETPIXELPROC)ReadPixelFromBuffer); + SetFunctionSetPixel((SETPIXELPROC)WritePixelToBuffer); + BufferInfo BI; LoadPalette("tileset\\Jungle.wpe",dwPalette); HANDLE hGrp; if (argc>1) @@ -40,20 +61,61 @@ int main(int argc, char* argv[]) HDC hDC = GetDC(0); GRPHEADER GrpInfo; if (GetGrpInfo(hGrp,&GrpInfo)==0) {GrpInfo.nFrames=0;GrpInfo.wMaxWidth=0;GrpInfo.wMaxHeight=0;} + BI.nWidth = GrpInfo.wMaxWidth; + BI.nHeight = GrpInfo.wMaxHeight; + BI.pBuffer = (DWORD *)malloc(BI.nWidth * BI.nHeight * sizeof(DWORD)); + WORD i,x,y; + DWORD j; + for (i = 0; i < BI.nWidth * BI.nHeight; i++) + BI.pBuffer[i] = 0xFFFFFFFF; //for (DWORD j=0;j<16;j++){ /*for (WORD i=0;i