mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-07 10:34:54 -06:00
Merge continued
git-svn-id: svn://ultimatepp.org/upp/trunk@10263 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
adf46bd64e
commit
2e4b276e07
3860 changed files with 1161787 additions and 438 deletions
102
uppdev/CDraw/PixelBlock.cpp
Normal file
102
uppdev/CDraw/PixelBlock.cpp
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#include "MDraw.h"
|
||||
|
||||
int PixelBlock::display;
|
||||
|
||||
void PixelBlock::Create0(int cx, int cy, bool section)
|
||||
{
|
||||
if(!display)
|
||||
Init();
|
||||
|
||||
hbmp = NULL;
|
||||
buffer = NULL;
|
||||
|
||||
size.cx = cx;
|
||||
size.cy = cy;
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
if(section) {
|
||||
TIMING("Create section");
|
||||
Buffer<byte> bibuffer(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
|
||||
BITMAPINFOHEADER *hi = (BITMAPINFOHEADER *) ~bibuffer;;
|
||||
BITMAPINFO *bi = (BITMAPINFO *)hi;
|
||||
|
||||
memset(bi, 0, sizeof(BITMAPINFOHEADER));
|
||||
hi->biSize = sizeof(BITMAPINFOHEADER);
|
||||
hi->biPlanes = 1;
|
||||
hi->biBitCount = 32;
|
||||
hi->biCompression = BI_RGB;
|
||||
hi->biSizeImage = 0;
|
||||
hi->biClrUsed = 0;
|
||||
hi->biClrImportant = 0;
|
||||
|
||||
hi->biWidth = size.cx;
|
||||
hi->biHeight = size.cy;
|
||||
|
||||
hbmp = CreateDIBSection(ScreenInfo().GetHandle(), bi, DIB_RGB_COLORS, (void **)&pixel, NULL, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
static dword helpbuffer[1600 * 1200];
|
||||
buffer = helpbuffer;
|
||||
// buffer = (dword *)GlobalAlloc(GMEM_FIXED, sizeof(dword) * cx * cy);
|
||||
pixel = buffer;
|
||||
}
|
||||
|
||||
|
||||
void PixelBlock::Create(int cx, int cy)
|
||||
{
|
||||
Clear();
|
||||
Create0(cx, cy);
|
||||
}
|
||||
|
||||
void PixelBlock::Clear()
|
||||
{
|
||||
if(hbmp)
|
||||
::DeleteObject(hbmp);
|
||||
// if(buffer)
|
||||
// GlobalFree(buffer);
|
||||
pixel = NULL;
|
||||
hbmp = NULL;
|
||||
size.cx = size.cy = 0;
|
||||
}
|
||||
|
||||
PixelBlock::~PixelBlock()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void PixelBlock::DrawRect(int x, int y, int cx, int cy, Color c)
|
||||
{
|
||||
RTIMING("DrawRect");
|
||||
dword color = c.GetRaw();
|
||||
dword *l = pixel + y * size.cx + x;
|
||||
while(cy--) {
|
||||
memsetd(l, color, cx);
|
||||
// memset(l, color, 2 * cx);
|
||||
l += size.cx;
|
||||
}
|
||||
}
|
||||
|
||||
int PixelBlock::LineDelta()
|
||||
{
|
||||
return size.cx;
|
||||
}
|
||||
|
||||
dword *PixelBlock::PointAdr(int x, int y)
|
||||
{
|
||||
return pixel + y * size.cx + x;
|
||||
}
|
||||
|
||||
PixelBlock::PixelBlock()
|
||||
{
|
||||
size.cx = size.cy = 0;
|
||||
hbmp = NULL;
|
||||
pixel = NULL;
|
||||
}
|
||||
|
||||
PixelBlock::PixelBlock(int cx, int cy, bool section)
|
||||
{
|
||||
Create0(cx, cy, section);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue