diff --git a/src/sys/graphics/main.cpp b/src/sys/graphics/main.cpp index 6f60670..779c077 100755 --- a/src/sys/graphics/main.cpp +++ b/src/sys/graphics/main.cpp @@ -21,7 +21,7 @@ buf = new TGfx0(); buf2 = new TGfx0(); font = new TDPFont(buf); - buf->create(400,400,(TPixelFmt *)&def_pixfmt_8bpp); + buf->create(400,400,def_pixfmt_8bpp); // buf2->create(400,400,(TPixelFmt *)&def_pixfmt_15bpp); buf2->alias(buf,0,3,8,8); buf2->putPixel(0,0,1); diff --git a/src/sys/graphics/objgfx30.cpp b/src/sys/graphics/objgfx30.cpp index cd1d841..392c4b6 100755 --- a/src/sys/graphics/objgfx30.cpp +++ b/src/sys/graphics/objgfx30.cpp @@ -226,11 +226,16 @@ void TGfx0::clone(TGfx0* SrcObject) { - + TPixelFmt pixfmt; + if (SrcObject->DataState==og_None) return; + SrcObject->getPixFmt(pixfmt); + create(SrcObject->MaxX+1,SrcObject->MaxY+1,pixfmt); + if (pal!=NULL) pal = SrcObject->pal; + copy(SrcObject); } // TGfx0::clone bool -TGfx0::create(UInt32 _xRes, UInt32 _yRes,TPixelFmt* _pixformat) { +TGfx0::create(UInt32 _xRes, UInt32 _yRes,TPixelFmt _pixformat) { /* * constructor TGfx0::create() * Allocates memory for a buffer of size _xRes by _yRes with @@ -243,7 +248,7 @@ if (LineOfs) free(LineOfs); if (pal) free(pal); } // if datastate - BPP = _pixformat->BPP; + BPP = _pixformat.BPP; bSize=_xRes*_yRes*((BPP+7) >> 3); Buffer = malloc(bSize); if (!Buffer) return FALSE; @@ -263,13 +268,13 @@ LineOfs[yy]=LineOfs[yy-1]+xRes; DataState = og_Owner; // For 8bpp modes the next part doesn't matter - RedFieldPosition=_pixformat->RedFieldPosition; - GreenFieldPosition=_pixformat->GreenFieldPosition; - BlueFieldPosition=_pixformat->BlueFieldPosition; + 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; + RedShifter=8-_pixformat.RedMaskSize; + GreenShifter=8-_pixformat.GreenMaskSize; + BlueShifter=8-_pixformat.BlueMaskSize; Owner = this; return TRUE; } // TGfx0::create @@ -304,6 +309,30 @@ } // else } // TGfx0::copy +UInt8 +TGfx0::getBPP(void) { + return BPP; +} // TGfx0:getBPP + +void* +TGfx0::getBufferPtr(void) { + return Buffer; +} // TGfx0::getBufferPtr + +og_DataState +TGfx0::getDataState(void) { + return DataState; +} // TGfx0::getDataState(void) + +UInt32* +TGfx0::getLineOfsPtr(void) { + return LineOfs; +} // TGfx0::getLineOfsPtr + +TRGB * +TGfx0::getPalPtr(void) { + return pal; +} // TGfx0::getPalPtr UInt32 TGfx0::getMaxX(void) { return MaxX; @@ -383,6 +412,17 @@ } // TGfx0::getPixel void +TGfx0::getPixFmt(TPixelFmt& pixfmt) { + pixfmt.BPP=BPP; + pixfmt.RedFieldPosition=RedFieldPosition; + pixfmt.GreenFieldPosition=GreenFieldPosition; + pixfmt.BlueFieldPosition=BlueFieldPosition; + pixfmt.RedMaskSize=8-RedShifter; + pixfmt.GreenMaskSize=8-GreenShifter; + pixfmt.BlueMaskSize=8-BlueShifter; +} // TGfx0::getPixFmt + +void TGfx0::horizLine(Int32 x1, Int32 x2, Int32 y, UInt32 colour) { } // TGfx0::horizLine diff --git a/src/sys/graphics/objgfx30.h b/src/sys/graphics/objgfx30.h index f5815be..2f8fa04 100755 --- a/src/sys/graphics/objgfx30.h +++ b/src/sys/graphics/objgfx30.h @@ -150,13 +150,19 @@ void bar(Int32, Int32, Int32, Int32, UInt32); // void bSpline void circle(Int32, Int32, UInt32, UInt32); - bool create(UInt32, UInt32, TPixelFmt*); + bool create(UInt32, UInt32, TPixelFmt); void clear(UInt32); void clone(TGfx0*); void copy(TGfx0*); + UInt8 getBPP(void); + void * getBufferPtr(void); + og_DataState getDataState(void); + UInt32 * getLineOfsPtr(void); + TRGB * getPalPtr(void); UInt32 getMaxX(void); UInt32 getMaxY(void); UInt32 getPixel(UInt32, UInt32); + void getPixFmt(TPixelFmt&); void horizLine(Int32, Int32, Int32, UInt32); void putPixel(UInt32, UInt32, UInt32); UInt32 RGB(UInt8, UInt8, UInt8);