/******************************************************* $Id$ *******************************************************/ #include "objgfx30.h" #include <stdlib.h> // TGfx0 constructor TGfx0::TGfx0(void) { DataState = og_None; Buffer = 0; LineOfs = 0; pal = 0; xRes = 0; yRes = 0; MaxX = 0; MaxY = 0; bSize = 0; lSize = 0; TransparentColor = 0; BPP = 0; RedShifter = 0; GreenShifter = 0; BlueShifter = 0; RedFieldPosition = 0; GreenFieldPosition = 0; BlueFieldPosition = 0; return; } // TGfx0::TGfx0() bool TGfx0::create(UInt32 _xRes, UInt32 _yRes,TPixelFmt* _pixformat) { UInt32 yy; if (DataState==og_Owner) { if (Buffer) free(Buffer); if (LineOfs) free(LineOfs); if (pal) free(pal); } // if datastate BPP = _pixformat->BPP; bSize=_xRes*_yRes*((BPP+7) >> 3); Buffer = malloc(bSize); if (!Buffer) return FALSE; lSize = _yRes*sizeof(UInt32); LineOfs = (UInt32*)malloc(lSize); if (!LineOfs) return FALSE; pal = (TRGB*)malloc(256*sizeof(TRGB)); if (!pal) return FALSE; MaxX=_xRes-1; xRes=_xRes; MaxY=_yRes-1; yRes=_yRes; LineOfs[0]=0; for (yy=1; yy<=MaxY; yy++) LineOfs[yy]=LineOfs[yy-1]+xRes*((BPP+7) >> 3); DataState = og_Owner; // For 8bpp modes the next part doesn't matter RedFieldPosition=_pixformat->RedFieldPosition; GreenFieldPosition=_pixformat->GreenFieldPosition; BlueFieldPosition=_pixformat->BlueFieldPosition; // The next part is only used by 15/16hpp RedShifter=8-_pixformat->RedMaskSize; GreenShifter=8-_pixformat->GreenMaskSize; BlueShifter=8-_pixformat->BlueMaskSize; Owner = this; return TRUE; } // TGfx0::create UInt32 TGfx0::getMaxX(void) { return MaxX; } // TGfx0::getMaxX UInt32 TGfx0::getMaxY(void) { return MaxY; } // TGfx0::getMaxY TGfx0::~TGfx0(void) { if (DataState == og_Owner) { if (pal) free(pal); if (Buffer) free(Buffer); if (LineOfs) free(LineOfs); } // if datastate pal=0; LineOfs=0; Buffer=0; bSize=0; lSize=0; DataState = og_None; return; } // TGfx0::~TGfx0()