Page 1 of 1

1.13c Color extension 8 bite to 24 bite

Posted: Mon Apr 23, 2018 7:26 am
by nnsky2011
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;
						}
	}

Re: 1.13c Color extension 8 bite to 24 bite

Posted: Mon Apr 23, 2018 7:58 pm
by k0r3l1k
Wow very cool.

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

Re: 1.13c Color extension 8 bite to 24 bite

Posted: Wed Apr 25, 2018 1:22 pm
by jessedazebra
.

Re: 1.13c Color extension 8 bite to 24 bite

Posted: Sat Nov 03, 2018 11:27 am
by Conqueror
How do I make it work?
Can it be incorporated into the PlugY source code?