Permalink
Browse files

RECT to Rect

  • Loading branch information...
1 parent 110f57d commit aa1b99c38df434e10ca7d68ef0cab355533451ea @grahamboree committed Oct 8, 2012
@@ -127,19 +127,19 @@ typedef unsigned char BYTE;
# define _T
# endif
-typedef struct tagRECT
+struct Rect
{
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
-} RECT;
+};
-typedef struct tagPOINT
+struct POINT
{
int32_t x;
int32_t y;
-} POINT;
+};
typedef struct tagRGBQUAD {
uint8_t rgbBlue;
View
@@ -207,7 +207,7 @@ class DLL_EXP CxImage
uint32_t dwFrameDelay; ///< used for GIF, MNG
int32_t xDPI; ///< horizontal resolution
int32_t yDPI; ///< vertical resolution
- RECT rSelectionBox; ///< bounding rectangle
+ Rect rSelectionBox; ///< bounding rectangle
uint8_t nAlphaMax; ///< max opacity (fade)
bool bAlphaPaletteEnabled; ///< true if alpha values in the palette are enabled.
bool bEnabled; ///< enables the painting functions
@@ -503,20 +503,20 @@ class DLL_EXP CxImage
/** \addtogroup Painting */ //@{
#if CXIMAGE_SUPPORT_WINDOWS
int32_t Blt(HDC pDC, int32_t x = 0, int32_t y = 0);
- HBITMAP Draw2HBITMAP(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, RECT* pClipRect, bool bSmooth);
+ HBITMAP Draw2HBITMAP(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, Rect* pClipRect, bool bSmooth);
HBITMAP MakeBitmap(HDC hdc = NULL, bool bTransparency = false);
HICON MakeIcon(HDC hdc = NULL, bool bTransparency = false);
HANDLE CopyToHandle();
bool CreateFromHANDLE(HANDLE hMem); //Windows objects (clipboard)
bool CreateFromHBITMAP(HBITMAP hbmp, HPALETTE hpal = 0, bool bTransparency = false); //Windows resource
bool CreateFromHICON(HICON hico, bool bTransparency = false);
- int32_t Draw(HDC hdc, int32_t x = 0, int32_t y = 0, int32_t cx = -1, int32_t cy = -1, RECT* pClipRect = 0, bool bSmooth = false, bool bFlipY = false);
- int32_t Draw(HDC hdc, const RECT& rect, RECT* pClipRect=NULL, bool bSmooth = false, bool bFlipY = false);
+ int32_t Draw(HDC hdc, int32_t x = 0, int32_t y = 0, int32_t cx = -1, int32_t cy = -1, Rect* pClipRect = 0, bool bSmooth = false, bool bFlipY = false);
+ int32_t Draw(HDC hdc, const Rect& rect, Rect* pClipRect=NULL, bool bSmooth = false, bool bFlipY = false);
int32_t Stretch(HDC hdc, int32_t xoffset, int32_t yoffset, int32_t xsize, int32_t ysize, uint32_t dwRop = SRCCOPY);
- int32_t Stretch(HDC hdc, const RECT& rect, uint32_t dwRop = SRCCOPY);
- int32_t Tile(HDC hdc, RECT* rc);
+ int32_t Stretch(HDC hdc, const Rect& rect, uint32_t dwRop = SRCCOPY);
+ int32_t Tile(HDC hdc, Rect* rc);
int32_t Draw2(HDC hdc, int32_t x = 0, int32_t y = 0, int32_t cx = -1, int32_t cy = -1);
- int32_t Draw2(HDC hdc, const RECT& rect);
+ int32_t Draw2(HDC hdc, const Rect& rect);
//int32_t DrawString(HDC hdc, int32_t x, int32_t y, const char* text, RGBQUAD color, const char* font, int32_t lSize=0, int32_t lWeight=400, uint8_t bItalic=0, uint8_t bUnderline=0, bool bSetAlpha=false);
int32_t DrawString(HDC hdc, int32_t x, int32_t y, const TCHAR* text, RGBQUAD color, const TCHAR* font, int32_t lSize = 0, int32_t lWeight = 400, uint8_t bItalic = 0, uint8_t bUnderline = 0, bool bSetAlpha = false);
// <VATI> extensions
@@ -607,7 +607,7 @@ class DLL_EXP CxImage
bool DecreaseBpp(uint32_t nbit, bool errordiffusion, RGBQUAD* ppal = 0, uint32_t clrimportant = 0);
bool Dither(int32_t method = 0);
bool Crop(int32_t left, int32_t top, int32_t right, int32_t bottom, CxImage* iDst = NULL);
- bool Crop(const RECT& rect, CxImage* iDst = NULL);
+ bool Crop(const Rect& rect, CxImage* iDst = NULL);
bool CropRotatedRectangle(int32_t topx, int32_t topy, int32_t width, int32_t height, float angle, CxImage* iDst = NULL);
bool Skew(float xgain, float ygain, int32_t xpivot = 0, int32_t ypivot = 0, bool bEnableInterpolation = false);
bool Expand(int32_t left, int32_t top, int32_t right, int32_t bottom, RGBQUAD canvascolor, CxImage* iDst = 0);
@@ -676,7 +676,7 @@ class DLL_EXP CxImage
bool FloodFill(const int32_t xStart, const int32_t yStart, const RGBQUAD cFillColor, const uint8_t tolerance = 0, uint8_t nOpacity = 255, const bool bSelectFilledArea = false, const uint8_t nSelectionLevel = 255);
bool Saturate(const int32_t saturation, const int32_t colorspace = 1);
bool ConvertColorSpace(const int32_t dstColorSpace, const int32_t srcColorSpace);
- int32_t OptimalThreshold(int32_t method = 0, RECT* pBox = 0, CxImage* pContrastMask = 0);
+ int32_t OptimalThreshold(int32_t method = 0, Rect* pBox = 0, CxImage* pContrastMask = 0);
bool AdaptiveThreshold(int32_t method = 0, int32_t nBoxSize = 64, CxImage* pContrastMask = 0, int32_t nBias = 0, float fGlobalLocalBalance = 0.5f);
bool RedEyeRemove(float strength = 0.8f);
bool Trace(RGBQUAD color_target, RGBQUAD color_trace);
@@ -726,14 +726,14 @@ class DLL_EXP CxImage
bool SelectionInvert();
bool SelectionMirror();
bool SelectionFlip();
- bool SelectionAddRect(RECT r, uint8_t level = 255);
- bool SelectionAddEllipse(RECT r, uint8_t level = 255);
+ bool SelectionAddRect(Rect r, uint8_t level = 255);
+ bool SelectionAddEllipse(Rect r, uint8_t level = 255);
bool SelectionAddPolygon(POINT* points, int32_t npoints, uint8_t level = 255);
bool SelectionAddColor(RGBQUAD c, uint8_t level = 255);
bool SelectionAddPixel(int32_t x, int32_t y, uint8_t level = 255);
bool SelectionCopy(CxImage& from);
bool SelectionIsInside(int32_t x, int32_t y);
- void SelectionGetBox(RECT& r);
+ void SelectionGetBox(Rect& r);
bool SelectionToHRGN(HRGN& region);
bool SelectionSplit(CxImage* dest);
uint8_t SelectionGet(const int32_t x, const int32_t y);
@@ -796,8 +796,8 @@ class DLL_EXP CxImage
CxImage* GetParent() const;
int32_t GetNumLayers() const;
#ifdef WIN32 //@HACK
- int32_t LayerDrawAll(HDC hdc, int32_t x = 0, int32_t y = 0, int32_t cx = -1, int32_t cy = -1, RECT* pClipRect = 0, bool bSmooth = false);
- int32_t LayerDrawAll(HDC hdc, const RECT& rect, RECT* pClipRect = NULL, bool bSmooth = false);
+ int32_t LayerDrawAll(HDC hdc, int32_t x = 0, int32_t y = 0, int32_t cx = -1, int32_t cy = -1, Rect* pClipRect = 0, bool bSmooth = false);
+ int32_t LayerDrawAll(HDC hdc, const Rect& rect, Rect* pClipRect = NULL, bool bSmooth = false);
#endif
//@}
#endif //CXIMAGE_SUPPORT_LAYERS
@@ -151,7 +151,7 @@ bool CxImageWMF::Decode(CxFile *hFile, int32_t nForceWidth, int32_t nForceHeight
if (hDC){
if (hBitmap){
- RECT rc = {0,0,cx,cy};
+ Rect rc = {0,0,cx,cy};
int32_t bpp = ::GetDeviceCaps(hDC, BITSPIXEL);
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hDC, hBitmap);
@@ -109,7 +109,7 @@ typedef struct tagMETAFILEHEADER
protected:
void ShrinkMetafile(int32_t &cx, int32_t &cy);
- bool CheckMetafileHeader(METAFILEHEADER *pmetafileheader);
+ BOOL CheckMetafileHeader(METAFILEHEADER *pmetafileheader);
HENHMETAFILE ConvertWmfFiletoEmf(CxFile *pFile, METAFILEHEADER *pmetafileheader);
HENHMETAFILE ConvertEmfFiletoEmf(CxFile *pFile, ENHMETAHEADER *pemfh);
@@ -3251,7 +3251,7 @@ bool CxImage::ConvertColorSpace(const int32_t dstColorSpace, const int32_t srcCo
* \return optimal threshold; -1 = error.
* \sa AdaptiveThreshold
*/
-int32_t CxImage::OptimalThreshold(int32_t method, RECT * pBox, CxImage* pContrastMask)
+int32_t CxImage::OptimalThreshold(int32_t method, Rect * pBox, CxImage* pContrastMask)
{
if (!pDib)
return false;
@@ -3491,7 +3491,7 @@ bool CxImage::AdaptiveThreshold(int32_t method, int32_t nBoxSize, CxImage* pCont
for (int32_t x=0; x<mw; x++){
info.nProgress = (int32_t)(100*(x+y*mw)/(mw*mh));
if (info.nEscape) break;
- RECT r;
+ Rect r;
r.left = x*nBoxSize;
r.right = r.left + nBoxSize;
r.bottom = y*nBoxSize;
@@ -3779,7 +3779,7 @@ bool CxImage::FloodFill(const int32_t xStart, const int32_t yStart, const RGBQUA
info.rSelectionBox.top = head.biHeight;
info.rSelectionBox.left = info.rSelectionBox.bottom = 0;
}
- RECT r;
+ Rect r;
SelectionGetBox(r);
for (int32_t y = r.bottom; y < r.top; y++)
{
@@ -908,7 +908,7 @@ uint32_t CxImage::UnDump(const uint8_t * src)
#if CXIMAGE_SUPPORT_SELECTION
if (src[n++]){
- RECT box = info.rSelectionBox;
+ Rect box = info.rSelectionBox;
if (SelectionCreate()){
info.rSelectionBox = box;
memcpy(pSelection, &src[n], head.biWidth * head.biHeight);
@@ -20,9 +20,9 @@ bool CxImage::SelectionIsValid()
/**
* Gets the smallest rectangle that contains the selection
*/
-void CxImage::SelectionGetBox(RECT& r)
+void CxImage::SelectionGetBox(Rect& r)
{
- memcpy(&r,&info.rSelectionBox,sizeof(RECT));
+ memcpy(&r,&info.rSelectionBox,sizeof(Rect));
}
////////////////////////////////////////////////////////////////////////////////
/**
@@ -105,12 +105,12 @@ bool CxImage::BlindSelectionIsInside(int32_t x, int32_t y)
/**
* Adds a rectangle to the existing selection.
*/
-bool CxImage::SelectionAddRect(RECT r, uint8_t level)
+bool CxImage::SelectionAddRect(Rect r, uint8_t level)
{
if (pSelection==NULL) SelectionCreate();
if (pSelection==NULL) return false;
- RECT r2;
+ Rect r2;
if (r.left<r.right) {r2.left=r.left; r2.right=r.right; } else {r2.left=r.right ; r2.right=r.left; }
if (r.bottom<r.top) {r2.bottom=r.bottom; r2.top=r.top; } else {r2.bottom=r.top ; r2.top=r.bottom; }
@@ -133,7 +133,7 @@ bool CxImage::SelectionAddRect(RECT r, uint8_t level)
/**
* Adds an ellipse to the existing selection.
*/
-bool CxImage::SelectionAddEllipse(RECT r, uint8_t level)
+bool CxImage::SelectionAddEllipse(Rect r, uint8_t level)
{
if (pSelection==NULL) SelectionCreate();
if (pSelection==NULL) return false;
@@ -201,7 +201,7 @@ bool CxImage::SelectionCopy(CxImage &from)
if (pSelection==NULL) pSelection = (uint8_t*)malloc(head.biWidth * head.biHeight);
if (pSelection==NULL) return false;
memcpy(pSelection,from.pSelection,head.biWidth * head.biHeight);
- memcpy(&info.rSelectionBox,&from.info.rSelectionBox,sizeof(RECT));
+ memcpy(&info.rSelectionBox,&from.info.rSelectionBox,sizeof(Rect));
return true;
}
////////////////////////////////////////////////////////////////////////////////
@@ -218,7 +218,7 @@ bool CxImage::SelectionAddPolygon(POINT *points, int32_t npoints, uint8_t level)
if (pSelection==NULL) return false;
uint8_t* plocal = (uint8_t*)calloc(head.biWidth*head.biHeight, 1);
- RECT localbox = {head.biWidth,0,0,head.biHeight};
+ Rect localbox = {head.biWidth,0,0,head.biHeight};
int32_t x,y,i=0;
POINT *current;
@@ -266,7 +266,7 @@ bool CxImage::SelectionAddPolygon(POINT *points, int32_t npoints, uint8_t level)
}
}
- RECT r2;
+ Rect r2;
if (current->x < next->x) {r2.left=current->x; r2.right=next->x; } else {r2.left=next->x ; r2.right=current->x; }
if (current->y < next->y) {r2.bottom=current->y; r2.top=next->y; } else {r2.bottom=next->y ; r2.top=current->y; }
if (localbox.top < r2.top) localbox.top = max(0L,min(head.biHeight-1,r2.top+1));
@@ -405,7 +405,7 @@ bool CxImage::SelectionAddColor(RGBQUAD c, uint8_t level)
if (pSelection==NULL) SelectionCreate();
if (pSelection==NULL) return false;
- RECT localbox = {head.biWidth,0,0,head.biHeight};
+ Rect localbox = {head.biWidth,0,0,head.biHeight};
for (int32_t y = 0; y < head.biHeight; y++){
for (int32_t x = 0; x < head.biWidth; x++){
@@ -2152,7 +2152,7 @@ bool CxImage::CropRotatedRectangle( int32_t topx, int32_t topy, int32_t width, i
return true;
}
////////////////////////////////////////////////////////////////////////////////
-bool CxImage::Crop(const RECT& rect, CxImage* iDst)
+bool CxImage::Crop(const Rect& rect, CxImage* iDst)
{
return Crop(rect.left, rect.top, rect.right, rect.bottom, iDst);
}
@@ -799,7 +799,7 @@ bool CxImage::CreateFromHICON(HICON hico, bool bTransparency)
}
#endif //_WIN32_WCE
////////////////////////////////////////////////////////////////////////////////
-int32_t CxImage::Draw(HDC hdc, const RECT& rect, RECT* pClipRect, bool bSmooth, bool bFlipY)
+int32_t CxImage::Draw(HDC hdc, const Rect& rect, Rect* pClipRect, bool bSmooth, bool bFlipY)
{
return Draw(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, pClipRect,bSmooth, bFlipY);
}
@@ -818,7 +818,7 @@ int32_t CxImage::Draw(HDC hdc, const RECT& rect, RECT* pClipRect, bool bSmooth,
* \param bFlipY : draws a mirror image along the y-axis
* \return true if everything is ok
*/
-int32_t CxImage::Draw(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, RECT* pClipRect, bool bSmooth, bool bFlipY)
+int32_t CxImage::Draw(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, Rect* pClipRect, bool bSmooth, bool bFlipY)
{
if((pDib==0)||(hdc==0)||(cx==0)||(cy==0)||(!info.bEnabled)) return 0;
@@ -833,7 +833,7 @@ int32_t CxImage::Draw(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, REC
return 0;
#if !defined (_WIN32_WCE)
- RECT mainbox; // (experimental)
+ Rect mainbox; // (experimental)
if (pClipRect){
GetClipBox(hdc,&mainbox);
HRGN rgn = CreateRectRgnIndirect(pClipRect);
@@ -843,7 +843,7 @@ int32_t CxImage::Draw(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, REC
#endif
//find the smallest area to paint
- RECT clipbox,paintbox;
+ Rect clipbox,paintbox;
GetClipBox(hdc,&clipbox);
paintbox.top = min(clipbox.bottom,max(clipbox.top,y));
@@ -1142,7 +1142,7 @@ int32_t CxImage::Draw(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, REC
* \return HBITMAP handle, NULL in case of error
* \sa MakeBitmap
*/
-HBITMAP CxImage::Draw2HBITMAP(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, RECT* pClipRect, bool bSmooth)
+HBITMAP CxImage::Draw2HBITMAP(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, Rect* pClipRect, bool bSmooth)
{
if((pDib==0)||(hdc==0)||(cx==0)||(cy==0)||(!info.bEnabled)) return 0;
@@ -1157,7 +1157,7 @@ HBITMAP CxImage::Draw2HBITMAP(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t
return 0;
#if !defined (_WIN32_WCE)
- RECT mainbox; // (experimental)
+ Rect mainbox; // (experimental)
if (pClipRect){
GetClipBox(hdc,&mainbox);
HRGN rgn = CreateRectRgnIndirect(pClipRect);
@@ -1169,7 +1169,7 @@ HBITMAP CxImage::Draw2HBITMAP(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t
HBITMAP TmpBmp;
//find the smallest area to paint
- RECT clipbox,paintbox;
+ Rect clipbox,paintbox;
GetClipBox(hdc,&clipbox);
paintbox.top = min(clipbox.bottom,max(clipbox.top,y));
@@ -1435,7 +1435,7 @@ HBITMAP CxImage::Draw2HBITMAP(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t
}
////////////////////////////////////////////////////////////////////////////////
-int32_t CxImage::Draw2(HDC hdc, const RECT& rect)
+int32_t CxImage::Draw2(HDC hdc, const Rect& rect)
{
return Draw2(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
@@ -1471,7 +1471,7 @@ int32_t CxImage::Draw2(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy)
} else {
// draw image with transparent background
const int32_t safe = 0; // or else GDI fails in the following - sometimes
- RECT rcDst = {x+safe, y+safe, x+cx, y+cy};
+ Rect rcDst = {x+safe, y+safe, x+cx, y+cy};
if (RectVisible(hdc, &rcDst)){
/////////////////////////////////////////////////////////////////
// True Mask Method - Thanks to Paul Reynolds and Ron Gery
@@ -1520,7 +1520,7 @@ int32_t CxImage::Draw2(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy)
return 1;
}
////////////////////////////////////////////////////////////////////////////////
-int32_t CxImage::Stretch(HDC hdc, const RECT& rect, uint32_t dwRop)
+int32_t CxImage::Stretch(HDC hdc, const Rect& rect, uint32_t dwRop)
{
return Stretch(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, dwRop);
}
@@ -1554,7 +1554,7 @@ int32_t CxImage::Stretch(HDC hdc, int32_t xoffset, int32_t yoffset, int32_t xsiz
* \param rc : tiled rectangle in the output device context
* \return true if everything is ok
*/
-int32_t CxImage::Tile(HDC hdc, RECT *rc)
+int32_t CxImage::Tile(HDC hdc, Rect *rc)
{
if((pDib)&&(hdc)&&(rc)) {
int32_t w = rc->right - rc->left;
@@ -1567,7 +1567,7 @@ int32_t CxImage::Tile(HDC hdc, RECT *rc)
z=bx;
for (x = 0 ; x < w ; x += z){
if ((x+z)>w) z=w-x;
- RECT r = {rc->left + x,rc->top + y,rc->left + x + z,rc->top + y + by};
+ Rect r = {rc->left + x,rc->top + y,rc->left + x + z,rc->top + y + by};
Draw(hdc,rc->left + x, rc->top + y,-1,-1,&r);
}
}
@@ -1612,10 +1612,10 @@ int32_t CxImage::DrawString(HDC hdc, int32_t x, int32_t y, const TCHAR* text, RG
//draw the text
SetBkMode(TmpDC,OPAQUE);
//Set text position;
- RECT pos = {0,0,0,0};
+ Rect pos = {0,0,0,0};
//int32_t len = (int32_t)strlen(text);
int32_t len = (int32_t)_tcslen(text); // For UNICODE support
- ::DrawText(TmpDC,text,len,&pos,DT_CALCRECT);
+ ::DrawText(TmpDC,text,len,&pos,DT_CALCRect);
pos.right+=pos.bottom; //for italics
//Preparing Bitmap Info
@@ -1705,7 +1705,7 @@ int32_t CxImage::DrawStringEx(HDC hdc, int32_t x, int32_t y, CXTEXTINFO *pTextTy
SetBkColor(TmpDC,RGB(0,0,0));
SetBkMode(TmpDC,OPAQUE);
//Set text position;
- RECT pos = {0,0,0,0};
+ Rect pos = {0,0,0,0};
// get text length and number of lines
int32_t i=0, numlines=1, len=(int32_t)_tcsclen(pTextType->text);
@@ -1715,7 +1715,7 @@ int32_t CxImage::DrawStringEx(HDC hdc, int32_t x, int32_t y, CXTEXTINFO *pTextTy
numlines++;
}
- ::DrawText(TmpDC, pTextType->text, len, &pos, /*DT_EDITCONTROL|DT_EXTERNALLEADING|*/DT_NOPREFIX | DT_CALCRECT );
+ ::DrawText(TmpDC, pTextType->text, len, &pos, /*DT_EDITCONTROL|DT_EXTERNALLEADING|*/DT_NOPREFIX | DT_CALCRect );
// increase only if it's really italics, and only one line height
if ( pTextType->lfont.lfItalic )
@@ -1876,12 +1876,12 @@ void CxImage::InitTextInfo( CXTEXTINFO *txt )
#if CXIMAGE_SUPPORT_LAYERS
////////////////////////////////////////////////////////////////////////////////
-int32_t CxImage::LayerDrawAll(HDC hdc, const RECT& rect, RECT* pClipRect, bool bSmooth)
+int32_t CxImage::LayerDrawAll(HDC hdc, const Rect& rect, Rect* pClipRect, bool bSmooth)
{
return LayerDrawAll(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, pClipRect,bSmooth);
}
////////////////////////////////////////////////////////////////////////////////
-int32_t CxImage::LayerDrawAll(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, RECT* pClipRect, bool bSmooth)
+int32_t CxImage::LayerDrawAll(HDC hdc, int32_t x, int32_t y, int32_t cx, int32_t cy, Rect* pClipRect, bool bSmooth)
{
int32_t n=0;
CxImage* pLayer;

0 comments on commit aa1b99c

Please sign in to comment.