1.13c Color extension 8 bite to 24 bite

This forum is for discussions on how to edit what can not be edited through the txt files, needless to say this isn't about battle net hacking.

Moderators: Nefarius, Havvoric

Post Reply
nnsky2011
Posts: 4
Joined: Thu Jan 05, 2017 9:36 am

1.13c Color extension 8 bite to 24 bite

Post by nnsky2011 » Mon Apr 23, 2018 7:26 am

Image
load file

Code: Select all

int loadfileprocaddress = (int)LoadLibrary("D2WIN.DLL") + 0x7c60;
__forceinline char* loadfile(char* filename) {
	_asm mov eax, filename;
	return ((char* (_stdcall*)(DWORD, DWORD))loadfileprocaddress)(0, 0);
};
load bitmap

Code: Select all

char* file = loadfile(filename1);
	if (!file)return;
	if (*(WORD*)file == 0x4d42) {
		BITMAPFILEHEADER* bmpfileheader = (BITMAPFILEHEADER*)file;//文件头  
		BITMAPINFOHEADER* bmpinfoheader = (BITMAPINFOHEADER*)(file + sizeof(BITMAPFILEHEADER));//位图头  
		BITMAPINFO* bmpinfo = (BITMAPINFO*)bmpinfoheader;//位图信息  
		HDC hdc = GetDC(0);
		HBITMAP hbitmap = CreateCompatibleBitmap(hdc, bmpinfo->bmiHeader.biWidth, bmpinfo->bmiHeader.biHeight);
		ReleaseDC(0, hdc);
		hdc = CreateCompatibleDC(0);
		SelectObject(hdc, hbitmap);
		SetDIBits(hdc, hbitmap, 0, bmpinfo->bmiHeader.biHeight, file + bmpfileheader->bfOffBits, bmpinfo, 0);
		DeleteDC(hdc);
		i->x = bmpinfo->bmiHeader.biWidth;
		i->y = bmpinfo->bmiHeader.biHeight;
		i->bits = new int[i->x*i->y];
		GetBitmapBits(hbitmap, i->x*i->y * sizeof(int), i->bits);
		dc6bits->dwTermination = (int)i;
		DeleteObject(hbitmap);
	}
draw bitmap

Code: Select all

int TickCount = GetTickCount() / 40;//25f/s
	for (int i = 0; i < drawersize && drawer[i].type; i++) {
		if (drawer[i].type == 1)//bitmap
			if (drawer[i].h->type == 0) {//Static graph
				for (int x = 0; x < drawer[i].h->x; x++)for (int y = 0; y < drawer[i].h->y; y++)
					if ((x + drawer[i].x) >= 0)if ((y + drawer[i].y) >= 0)if ((x + drawer[i].x) < *wSrc)if ((y + drawer[i].y) < *hSrc)
						if (bits[x + drawer[i].x + (drawer[i].y + y + *hSrc) * *wSrc] == 0xffffff)
							bits[x + drawer[i].x + (drawer[i].y + y) * *wSrc] = drawer[i].h->bits[x + y * drawer[i].h->x];
			}
			else {//Dynamic graph
				int *gifbits = &drawer[i].h->bits[drawer[i].h->x*drawer[i].h->y*(TickCount%drawer[i].h->type)];
				for (int x = 0; x < drawer[i].h->x; x++)for (int y = 0; y < drawer[i].h->y; y++)
					if ((x + drawer[i].x) >= 0)if ((y + drawer[i].y) >= 0)if ((x + drawer[i].x) < *wSrc)if ((y + drawer[i].y) < *hSrc)
						if (bits[x + drawer[i].x + (drawer[i].y + y + *hSrc) * *wSrc] == 0xffffff)
							if (gifbits[x + y * drawer[i].h->x])
								bits[x + drawer[i].x + (drawer[i].y + y) * *wSrc] = gifbits[x + y * drawer[i].h->x];
			}
			if (drawer[i].type == 2)//mask
				for (int x = drawer[i].rect.left; x < drawer[i].rect.right; x++)for (int y = drawer[i].rect.top; y < drawer[i].rect.bottom; y++)
					if (x >= 0)if (y >= 0)if (x < *wSrc)if (y < *hSrc)
						if (bits[x + (y + *hSrc) * *wSrc] == 0xffffff) {
							*(BYTE*)&bits[x + y * *wSrc] = (int)*(BYTE*)&bits[x + y * *wSrc] * (drawer[i].color & 0xff) / 0xff;
							*((BYTE*)&bits[x + y * *wSrc] + 1) = (int)*((BYTE*)&bits[x + y * *wSrc] + 1) * (drawer[i].color >> 8 & 0xff) / 0xff;
							*((BYTE*)&bits[x + y * *wSrc] + 2) = (int)*((BYTE*)&bits[x + y * *wSrc] + 2) * (drawer[i].color >> 16 & 0xff) / 0xff;
						}
	}

User avatar
k0r3l1k
Moderator
Angel
Posts: 631
Joined: Sun Sep 09, 2007 3:11 am
Location: Arizona, Prescott
United States of America

Re: 1.13c Color extension 8 bite to 24 bite

Post by k0r3l1k » Mon Apr 23, 2018 7:58 pm

Wow very cool.

Not a bad trick. Great for menu screens, maybe even a few ui elements.
Image

jessedazebra
Junior Member
Paladin
Posts: 144
Joined: Sun Nov 11, 2012 9:46 am
Zimbabwe

Re: 1.13c Color extension 8 bite to 24 bite

Post by jessedazebra » Wed Apr 25, 2018 1:22 pm

.
Last edited by jessedazebra on Sat Feb 19, 2022 9:52 am, edited 1 time in total.

User avatar
Conqueror
Posts: 62
Joined: Mon Oct 23, 2017 8:03 pm
Argentina

Re: 1.13c Color extension 8 bite to 24 bite

Post by Conqueror » Sat Nov 03, 2018 11:27 am

How do I make it work?
Can it be incorporated into the PlugY source code?

Post Reply

Return to “Code Editing”