์์ :)
https://github.com/eazuooz/WindowAPI/commit/c5146992a87f43d612e3307fa4c52964a51027c5
Pixel Collision · eazuooz/WindowAPI@c514699
Show file tree Showing 4 changed files with 45 additions and 5 deletions.
github.com
๋นํธ๋งต(Bitmap) ๊ทธ๋ํฝ
๋นํธ๋งต ๊ทธ๋ํฝ์ ๊ฐ๋จํ ๋งํด ์๋ก ๋ค๋ฅธ ์ (ํฝ์ )๋ค์ ์กฐํฉ์ผ๋ก ๊ทธ๋ ค์ง๋ ์ด๋ฏธ์ง ํํ ๋ฐฉ์์ ๋๋ค. ๋นํธ๋งต ์ด๋ฏธ์ง๋ ์ ๊ตํ๊ณ ํ๋ คํ ํํ์ด ๊ฐ๋ฅํ์ฌ, ์ฃผ๋ก ์ฌ์ง ์ด๋ฏธ์ง์ ์ฃผ๋ก ์ฌ์ฉ๋ฉ๋๋ค. ๋นํธ๋งต ์ด๋ฏธ์ง๋ ํฌ๊ธฐ๋ฅผ ๋๋ฆฌ๊ฑฐ๋ ์ค์ด๋ฉด ์๋ณธ ์ด๋ฏธ์ง์ ์์์ด ๊ฐ๋ ๊ฒ์ด ํน์ง์ด๋ฉฐ, ์ฐ๋ฆฌ๋ ํํ ์ด๊ฒ์ '์ด๋ฏธ์ง๊ฐ ๊นจ์ก๋ค'๋ผ๊ณ ํํํฉ๋๋ค.
Bitmap ํ์ผ์ ๊ฐ๋ก X ์ธ๋ก ํฌ๊ธฐ์ ํฝ์ ๋ค๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
ํด๋น ๋นํธ๋งต์ X, Y ์์น์ ์๋ ํฝ์ ์ ๊ฐ์ ๊ฐ์ ธ์ค๊ฑฐ๋ ๋๋ ์์ ํ ์๋ ์์ต๋๋ค.
ํฝ์ ๊ตฌ์กฐ์ฒด
struct Pixel
{
BYTE R;
BYTE G;
BYTE B;
BYTE A;
Pixel(BYTE r, BYTE g, BYTE b, BYTE a)
: R(r), G(g), B(b), A(a)
{
}
};
Set, Get ํฝ์ ํจ์
Pixel Image::GetPixel(int x, int y)
{
y = mHeight - (y + 1);
Pixel* pPixel = (Pixel*)mBitmap;
pPixel += (mWidth * y + x);
return *pPixel;
}
void Image::SetPixel(int x, int y, Pixel pixel)
{
// ๋นํธ๋งต ์ขํ๋ ์ข์ธก ์๋จ์ด 0,0 ์ด๊ธฐยย๋ฌธ์ ์๋์ฐ ์ขํ์์
// ์ฌ์ฉํ๋ ค๋ฉด y๋ฅผ ๋ฐ๋๋ก ๋ฐ๊พธ์ด์ฃผ์ดh๋ค.
y = mHeight - (y + 1);
Pixel* pPixel = (Pixel*)mBitmap;
pPixel += (mWidth * y + x);
*pPixel = pixel;
}
'๐ Development Study > ๐ป Win32API' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Sound (0) | 2022.11.09 |
---|---|
Gravity (0) | 2022.11.09 |
UIManager, UIBase (0) | 2022.11.09 |
Tile Map (0) | 2022.11.02 |
Clone Object(๋ณต์ฌ ์์ฑ์) (0) | 2022.10.26 |
๋๊ธ