void MRECT::ScaleAreaRes(void) { float x = MGetWorkspaceWidth()/(float)640; float y = MGetWorkspaceHeight()/(float)480; ScaleArea(x, y); }
void sRect::ScaleAreaRes(void) { float x = CCGetWorkspaceWidth()/(float)640; float y = CCGetWorkspaceHeight()/(float)480; ScaleArea(x, y); }
void PreviewRenderer::SetPreviewPosition(int iX, int iY, int iWidth, int iHeight) { ScaleArea(AlgorithmRemote::GetRequiredOverlapFactor(), iX, iY, iWidth, iHeight); /* Clamp bounds. */ iX = clamp(iX, 0, Source.m_iWidth); iY = clamp(iY, 0, Source.m_iHeight); iWidth = clamp(iWidth, 0, Source.m_iWidth - iX); iHeight = clamp(iHeight, 0, Source.m_iHeight - iY); /* If there's an overlap between the old position and the new position, optimize by * moving the old data to the new position and only blitting in the changed data. */ int iFromX = 0, iFromY = 0; int iToX = 0, iToY = 0; if(iX < Image.iX) iToX += Image.iX - iX; if(iX > Image.iX) iFromX += iX - Image.iX; if(iY < Image.iY) iToY += Image.iY - iY; if(iY > Image.iY) iFromY += iY - Image.iY; CImg temp; temp.Alloc(iWidth, iHeight, 1, 4); /* Copy the area within the image that's moved. This usually covers most of the image, and * it's much faster since we don't need to do any conversions. */ int iMoveWidth = min(Image.PreviewImage.m_iWidth, iWidth) - iToX - iFromX; int iMoveHeight = min(Image.PreviewImage.m_iHeight, iHeight) - iToY - iFromY; iMoveWidth = max(0, iMoveWidth); iMoveHeight = max(0, iMoveHeight); for(int y = 0; y < iMoveHeight; ++y) { const uint8_t *pFrom = Image.PreviewImage.ptr(iFromX, iFromY+y); uint8_t *pTo = temp.ptr(iToX, iToY+y); memmove(pTo, pFrom, iMoveWidth * Image.PreviewImage.m_iBytesPerChannel * Image.PreviewImage.m_iChannels); } /* Copy the edges; this part needs to be converted. Top edge:*/ if(iToY > 0) { CImg SrcRegion; SrcRegion.Hold(Source, iX, iY, iWidth, iToY); CImg DestRegion; DestRegion.Hold(temp, 0, 0, iWidth, iToY); SetFromImage(gFilterRecord, SrcRegion, DestRegion); } /* Top edge: */ if(iMoveHeight + iToY < iHeight) { int iYToCopy = iMoveHeight + iToY; CImg SrcRegion; SrcRegion.Hold(Source, iX, iY + iYToCopy, iWidth, iHeight - iYToCopy); CImg DestRegion; DestRegion.Hold(temp, 0, iYToCopy, iWidth, iHeight - iYToCopy); SetFromImage(gFilterRecord, SrcRegion, DestRegion); } /* Left edge: */ if(iToX > 0) { CImg SrcRegion; SrcRegion.Hold(Source, iX, iY, iToX, iHeight); CImg DestRegion; DestRegion.Hold(temp, 0, 0, iToX, iHeight); SetFromImage(gFilterRecord, SrcRegion, DestRegion); } /* Right edge: */ if(iMoveWidth + iToX < iWidth) { int iXToCopy = iMoveWidth + iToX; CImg SrcRegion; SrcRegion.Hold(Source, iX + iXToCopy, iY, iWidth - iXToCopy, iHeight); CImg DestRegion; DestRegion.Hold(temp, iXToCopy, 0, iWidth - iXToCopy, iHeight); SetFromImage(gFilterRecord, SrcRegion, DestRegion); } temp.Swap(Image.PreviewImage); Image.iX = iX; Image.iY = iY; }
void MRECT::ScaleAreaRes() { float x = MGetWorkspaceWidth() / 640.f; float y = MGetWorkspaceHeight() / 480.f; ScaleArea(x, y); }