hcavolsdsadgadsg I'm a spammer Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Feb 24, 2010 10:53 pm Post subject: |
|
|
here is this abortion of code if anyone is interested in case someone wants to use it for whatever.
try not to shit yourself.
Code: | #define DIB_RGB(r,g,b)((COLORREF)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
#include <Windows.h>
int __cdecl main (void);
int __cdecl mainCRTStartup (void) { return main(); }
int __cdecl main(void)
{
//////////////////////////////////////////////////////////////////////////
HDC hdc,
hdcMem;
HBITMAP dib,
hbmOld;
BITMAPINFO bi;
DWORD* bits;
//////////////////////////////////////////////////////////////////////////
int SCREEN_HEIGHT = 512;
int SCREEN_WIDTH = 512;
int W_SIZE = (512 - 1);
int SCRBUF_SIZE = (SCREEN_WIDTH * SCREEN_HEIGHT) * 4;
//////////////////////////////////////////////////////////////////////////
memset(&bi, 0, sizeof(bi));
bi.bmiHeader.biSize = sizeof(BITMAPINFO);
bi.bmiHeader.biWidth = SCREEN_WIDTH;
bi.bmiHeader.biHeight = -SCREEN_HEIGHT; //top down
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 32;
hdc = GetDC(NULL);
hdcMem = CreateCompatibleDC(hdc);
dib = CreateDIBSection(hdc, &bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
hbmOld = (HBITMAP)SelectObject(hdcMem, dib);
while(!GetAsyncKeyState(VK_ESCAPE))
{
COLORREF c;
int x, y, n;
for(n = 0; n < W_SIZE; n++) //number of "munches"
{
for(y = 0; y < W_SIZE; y++)
{
for(x = 0; x < W_SIZE; x++)
{
DWORD* dst = bits + (y * SCREEN_WIDTH + x);
//play with the comparison for fun results
if((x ^ y) < n) //the divide is for 512, meh
c = DIB_RGB((n / 2) ^ 255, (y / 2) ^ 255, (x / 2) ^ 255); //xor to 'reverse' the values 0 ^ 255 = 255... so
else //start at bright colors rather than 0 / black
c = 0x00000000; //x, y, and n all increase at different intervals
*dst = c; //handy for a nice gradient effect
} //be sure to keep colors in 255 range... might have to divide
}
BitBlt(hdc, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hdcMem, 0, 0, SRCCOPY);
memset(bits, 0, SCRBUF_SIZE);
Sleep(20); //1000 / x = fps, 50 is smooth and light on cpu
} //performance is almost directly proportional to number of pixels
} //keep resolution low if speed is an issue
SelectObject(hdcMem, hbmOld);
DeleteObject(dib);
ReleaseDC(NULL, hdc);
DeleteDC(hdcMem);
return 0;
} |
|
|