//--------------------------------------------------------------------------- #pragma hdrstop #include "Reflection.h" //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- __fastcall TReflection::TReflection() { FVScroll = 0; FHScroll = 0; FZoom = 1; FDirection = D_LR; FBitmapWidth = 0; FBitmapHeight = 0; FOriginRange.left = 0; FOriginRange.right = 0; FOriginRange.top = 0; FOriginRange.bottom = 0; FDstRange.left = 0; FDstRange.right = 0; FDstRange.top = 0; FDstRange.bottom = 0; FBitmap = NULL; FMask = NULL; FBackupBitmap = NULL; FBackupMask = NULL; FRgb = NULL; backupPositionX = 0; backupPositionY = 0; } //--------------------------------------------------------------------------- __fastcall TReflection::~TReflection() { if (FBackupBitmap) delete FBackupBitmap; if (FBackupMask) delete FBackupMask; if (FRgb) { delete[] FRgb; FRgb = NULL; } } //--------------------------------------------------------------------------- void __fastcall TReflection::SetReflection(TUnionBitmap *Bitmap, TUnionBitmap *Mask, RECT range, TypeDirection direction, bool getHalf, TLRB getImageDirection, TLRB useDirection) { FOriginRange.left = range.left; FOriginRange.right = range.right; FOriginRange.top = range.top; FOriginRange.bottom = range.bottom; FDirection = direction; FWorkSide = useDirection; if (getHalf){ FBitmapWidth = range.right - range.left; FBitmapHeight = range.bottom - range.top; if (FDirection == D_LR){ FDstRange.top = range.top; FDstRange.bottom = range.bottom; if (getImageDirection == D_LEFT){ FDstRange.left = range.left; FDstRange.right = range.right + FBitmapWidth; } else if (getImageDirection == D_RIGHT){ FDstRange.left = range.left - FBitmapWidth; FDstRange.right = range.right; } } else if (FDirection == D_TB){ FDstRange.left = range.left; FDstRange.right = range.right; if (getImageDirection == D_TOP){ FDstRange.top = range.top; FDstRange.bottom = range.bottom + FBitmapHeight; } else if (getImageDirection == D_BOTTOM){ FDstRange.top = range.top - FBitmapHeight; FDstRange.bottom = range.bottom; } } FBitmapRange.left = range.left; FBitmapRange.top = range.top; FBitmapRange.right = range.right; FBitmapRange.bottom = range.bottom; } else { //getImageDirection == FWorkSide ÀÓ if (FDirection == D_LR){ FBitmapWidth = (range.right - range.left)/2; FBitmapHeight = range.bottom - range.top; FDstRange.left = range.left; FDstRange.right = range.left + FBitmapWidth*2; FDstRange.top = range.top; FDstRange.bottom = range.bottom; if (FWorkSide == D_LEFT){ FBitmapRange.left = range.left; FBitmapRange.right = FBitmapRange.left + FBitmapWidth; } else if (FWorkSide == D_RIGHT){ FBitmapRange.left = range.left + FBitmapWidth; FBitmapRange.right = FBitmapRange.left + FBitmapWidth; //range.right; } FBitmapRange.top = range.top; FBitmapRange.bottom = FBitmapRange.top + FBitmapHeight; //range.bottom; } else if (FDirection == D_TB){ FBitmapWidth = range.right - range.left; FBitmapHeight = (range.bottom - range.top)/2; FDstRange.left = range.left; FDstRange.right = range.right; FDstRange.top = range.top; FDstRange.bottom = range.top + FBitmapHeight*2; if (FWorkSide == D_TOP){ FBitmapRange.top = range.top; FBitmapRange.bottom = FBitmapRange.top + FBitmapHeight; } else if (FWorkSide == D_BOTTOM){ FBitmapRange.top = range.top + FBitmapHeight; FBitmapRange.bottom = FBitmapRange.top + FBitmapHeight;//range.bottom; } FBitmapRange.left = range.left; FBitmapRange.right = FBitmapRange.left + FBitmapWidth;//range.right; } } if (FDirection == D_LR){ FScreenWidth = FBitmapWidth*2; FScreenHeight = FBitmapHeight; } else { FScreenWidth = FBitmapWidth; FScreenHeight = FBitmapHeight*2; } FBackupBitmap = new TUnionBitmap; if (Mask){ FBackupMask = new TUnionBitmap; } FBitmap = Bitmap; FMask = Mask; if (Bitmap->BitsPerPixel == 8){ FRgb = new RGBQUAD[256]; Bitmap->GetColors(0, 255, FRgb); FBackupBitmap->Create(range.right - range.left, range.bottom - range.top, 8, FRgb); FBackupBitmap->CopyFromRect(Bitmap, range.left, range.top, SRCCOPY); if (Mask) { FBackupMask->Create(range.right - range.left, range.bottom - range.top, 8, FRgb); FBackupMask->CopyFromRect(Mask, range.left, range.top, SRCCOPY); } } else { if (FRgb) { delete[] FRgb; FRgb = NULL; } FBackupBitmap->Create(range.right - range.left, range.bottom - range.top, 24); FBackupBitmap->CopyFromRect(Bitmap, range.left, range.top, SRCCOPY); if (Mask) { FBackupMask->Create(range.right - range.left, range.bottom - range.top, 1); FBackupMask->CopyFromRect(Mask, range.left, range.top, SRCCOPY); } } /* if (getHalf){ if (FDirection == D_LR){ if (getImageDirection == D_LEFT){ FBitmap->UnionStretchBltYreverse(FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, FBackupBitmap, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); if (Mask) FMask->UnionStretchBltYreverse(FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, FBackupMask, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); } else if (getImageDirection == D_RIGHT){ // } } else if (FDirection == D_TB){ if (getImageDirection == D_TOP){ FBitmap->UnionStretchBltXreverse(FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, FBackupBitmap, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); if (Mask) FMask->UnionStretchBltXreverse(FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, FBackupMask, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); } else if (getImageDirection == D_BOTTOM){ // } } } else { if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ FBitmap->UnionStretchBltYreverse(FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, FBackupBitmap, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); if (Mask) FMask->UnionStretchBltYreverse(FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, FBackupMask, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); } } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ FBitmap->UnionStretchBltXreverse(FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, FBackupBitmap, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); if (Mask) FMask->UnionStretchBltXreverse(FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, FBackupMask, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); } } } */ } //--------------------------------------------------------------------------- void __fastcall TReflection::SetZoom(double dZoom) { FZoom = dZoom; } //--------------------------------------------------------------------------- void __fastcall TReflection::SetHScroll(int nScroll) { if (nScroll != FHScroll){ FHScroll = nScroll; } } //--------------------------------------------------------------------------- void __fastcall TReflection::SetVScroll(int nScroll) { if (nScroll != FVScroll){ FVScroll = nScroll; } } //--------------------------------------------------------------------------- void __fastcall TReflection::SetDirection(TypeDirection direction) { FDirection = direction; } //--------------------------------------------------------------------------- void __fastcall TReflection::SetBackupUndoCount(int count) { FBackupUndoCount = count; } //--------------------------------------------------------------------------- void __fastcall TReflection::PaintScreen(TTexpiaBitmap *Screen) { int x = 0, y = 0; y = - FVScroll*FZoom; x = - FHScroll*FZoom; if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ FBitmap->AutoRepeatStretchBltNormal(Screen, x, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); FBitmap->AutoRepeatStretchBltYReverse(Screen, x + FBitmapWidth*FZoom, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } else { FBitmap->AutoRepeatStretchBltYReverse(Screen, x, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); FBitmap->AutoRepeatStretchBltNormal(Screen, x + FBitmapWidth*FZoom, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ FBitmap->AutoRepeatStretchBltNormal(Screen, x, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); FBitmap->AutoRepeatStretchBltXReverse(Screen, x, y + FBitmapHeight*FZoom, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } else { FBitmap->AutoRepeatStretchBltXReverse(Screen, x, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); FBitmap->AutoRepeatStretchBltNormal(Screen, x, y + FBitmapHeight*FZoom, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } } /* if (FDirection == D_LR){ if (x + FBitmapWidth*FZoom > 0 && y + FBitmapHeight*FZoom > 0) FBitmap->AutoRepeatStretchBltYReverse(Screen, x, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); FBitmap->AutoRepeatStretchBltNormal(Screen, x + FBitmapWidth*FZoom, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } else if (FDirection == D_TB){ if (x + FBitmapWidth*FZoom > 0 && x + FBitmapHeight*FZoom > 0) FBitmap->AutoRepeatStretchBltXReverse(Screen, x, y, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); FBitmap->AutoRepeatStretchBltNormal(Screen, x, y + FBitmapHeight*FZoom, FBitmapWidth*FZoom, FBitmapHeight*FZoom, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } */ } //--------------------------------------------------------------------------- void __fastcall TReflection::RectPaintScreen(RECT rtARRange, HDC dcViewRect, int nViewWidth, int nViewHeight, int nViewBitsPerPixel, double dZoom, RECT rtRealRect, bool bShowOnly) { // rtRealRectÀÇ right, bottomÀº width, heightÀÓ POINT realpoint, realpointS, realpointE; realpointS = FindOriginalPos(rtRealRect.left, rtRealRect.top); realpointE = FindOriginalPos(rtRealRect.left + rtRealRect.right, rtRealRect.top + rtRealRect.bottom); int width = rtRealRect.right; int height = rtRealRect.bottom; if (FDirection == D_LR){ realpoint.x = realpointS.x; realpoint.y = realpointS.y; if (realpoint.x < 0){ width += realpoint.x; realpoint.x = FBitmapRange.left; if (width <=0) return; } FBitmap->UnionStretchBlt(dcViewRect, 0, 0, width*dZoom, height*dZoom, realpoint.x, realpoint.y, width, height, SRCCOPY); } else if (FDirection == D_TB){ realpoint.x = realpointS.x; realpoint.y = realpointS.y; if (realpoint.y < 0){ height += realpoint.y; realpoint.y = FBitmapRange.top; if (height <=0) return; } FBitmap->UnionStretchBlt(dcViewRect, 0, 0, width*dZoom, height*dZoom, realpoint.x, realpoint.y, width, height, SRCCOPY); } /* if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ realpoint.x = realpointE.x; realpoint.y = realpointS.y; if (realpoint.x < 0){ width += realpoint.x; realpoint.x = FBitmapRange.left; if (width <=0) return; } TUnionBitmap *temp = new TUnionBitmap; temp->Create(width, height, FBitmap->BitsPerPixel, FRgb); temp->UnionStretchBltYreverse(0, 0, width, height, FBitmap, realpoint.x, realpoint.y, width, height, SRCCOPY); HDC dcTemp = temp->CreateDC(); StretchBlt(dcViewRect, 0, 0, width*dZoom, height*dZoom, dcTemp, 0, 0, width, height, SRCCOPY); DeleteDC(dcTemp); delete temp; } else if (FWorkSide == D_RIGHT){ realpoint.x = realpointS.x; realpoint.y = realpointS.y; if (realpoint.x < 0){ width += realpoint.x; realpoint.x = FBitmapRange.left; if (width <=0) return; } FBitmap->UnionStretchBlt(dcViewRect, 0, 0, width*dZoom, height*dZoom, realpoint.x, realpoint.y, width, height, SRCCOPY); } } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ realpoint.x = realpointS.x; realpoint.y = realpointE.y; if (realpoint.y < 0){ height += realpoint.y; realpoint.y = FBitmapRange.top; if (height <=0) return; } TUnionBitmap *temp = new TUnionBitmap; temp->Create(width, height, FBitmap->BitsPerPixel, FRgb); temp->UnionStretchBltXreverse(0, 0, width, height, FBitmap, realpoint.x, realpoint.y, width, height, SRCCOPY); HDC dcTemp = temp->CreateDC(); StretchBlt(dcViewRect, 0, 0, width*dZoom, height*dZoom, dcTemp, 0, 0, width, height, SRCCOPY); DeleteDC(dcTemp); delete temp; } else if (FWorkSide == D_BOTTOM){ realpoint.x = realpointS.x; realpoint.y = realpointS.y; if (realpoint.y < 0){ height += realpoint.y; realpoint.y = FBitmapRange.top; if (height <=0) return; } FBitmap->UnionStretchBlt(dcViewRect, 0, 0, width*dZoom, height*dZoom, realpoint.x, realpoint.y, width, height, SRCCOPY); } } */ } //--------------------------------------------------------------------------- void __fastcall TReflection::MakeApplyBitmap(TUnionBitmap *ApplyBitmap, TUnionBitmap *ApplyMask) { if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ ApplyBitmap->Create(FBitmapWidth*2, FBitmapHeight, FBitmap->BitsPerPixel, FRgb); ApplyBitmap->UnionStretchBlt(0, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyBitmap->UnionStretchBltYreverse(FBitmapWidth, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); if (ApplyMask && FMask) { ApplyMask->Create(FBitmapWidth*2, FBitmapHeight, FMask->BitsPerPixel, FRgb); ApplyMask->UnionStretchBlt(0, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyMask->UnionStretchBltYreverse(FBitmapWidth, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } } else { ApplyBitmap->Create(FBitmapWidth*2, FBitmapHeight, FBitmap->BitsPerPixel, FRgb); ApplyBitmap->UnionStretchBltYreverse(0, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyBitmap->UnionStretchBlt(FBitmapWidth, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); if (ApplyMask && FMask) { ApplyMask->Create(FBitmapWidth*2, FBitmapHeight, FMask->BitsPerPixel, FRgb); ApplyMask->UnionStretchBltYreverse(0, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyMask->UnionStretchBlt(FBitmapWidth, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } } } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ ApplyBitmap->Create(FBitmapWidth, FBitmapHeight*2, FBitmap->BitsPerPixel, FRgb); ApplyBitmap->UnionStretchBlt(0, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyBitmap->UnionStretchBltXreverse(0, FBitmapHeight, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); if (ApplyMask && FMask) { ApplyMask->Create(FBitmapWidth, FBitmapHeight*2, FMask->BitsPerPixel, FRgb); ApplyMask->UnionStretchBlt(0, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyMask->UnionStretchBltXreverse(0, FBitmapHeight, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } } else { ApplyBitmap->Create(FBitmapWidth, FBitmapHeight*2, FBitmap->BitsPerPixel, FRgb); ApplyBitmap->UnionStretchBltXreverse(0, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyBitmap->UnionStretchBlt(0, FBitmapHeight, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); if (ApplyMask && FMask) { ApplyMask->Create(FBitmapWidth, FBitmapHeight*2, FMask->BitsPerPixel, FRgb); ApplyMask->UnionStretchBltXreverse(0, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyMask->UnionStretchBlt(0, FBitmapHeight, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } } } /* if (FDirection == D_LR){ ApplyBitmap->Create(FBitmapWidth*2, FBitmapHeight, FBitmap->BitsPerPixel, FRgb); ApplyBitmap->UnionStretchBltYreverse(0, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyBitmap->UnionStretchBlt(FBitmapWidth, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); if (ApplyMask && FMask) { ApplyMask->Create(FBitmapWidth*2, FBitmapHeight, FMask->BitsPerPixel, FRgb); ApplyMask->UnionStretchBltYreverse(0, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyMask->UnionStretchBlt(FBitmapWidth, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } } else if (FDirection == D_TB){ ApplyBitmap->Create(FBitmapWidth, FBitmapHeight*2, FBitmap->BitsPerPixel, FRgb); ApplyBitmap->UnionStretchBltXreverse(0, 0, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyBitmap->UnionStretchBlt(0, FBitmapHeight, FBitmapWidth, FBitmapHeight, FBitmap, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); if (ApplyMask && FMask) { ApplyMask->Create(FBitmapWidth, FBitmapHeight*2, FMask->BitsPerPixel, FRgb); ApplyMask->UnionStretchBltXreverse(0, 0, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); ApplyMask->UnionStretchBlt(0, FBitmapHeight, FBitmapWidth, FBitmapHeight, FMask, FBitmapRange.left, FBitmapRange.top, FBitmapWidth, FBitmapHeight, SRCCOPY); } } */ } //--------------------------------------------------------------------------- void __fastcall TReflection::Apply(TUnionBitmap *dstBitmap, TUnionBitmap *dstMask) { TUnionBitmap *tempBitmap = NULL, *tempMask = NULL; tempBitmap = new TUnionBitmap; if (FMask) tempMask = new TUnionBitmap; if (FBitmap->BitsPerPixel == 8){ tempBitmap->Create(FBitmapWidth, FBitmapHeight, 8, FRgb); tempBitmap->CopyFromRect(FBitmap, FBitmapRange.left, FBitmapRange.top, SRCCOPY); if (FMask) { tempMask->Create(FBitmapWidth, FBitmapHeight, 8, FRgb); tempMask->CopyFromRect(FMask, FBitmapRange.left, FBitmapRange.top, SRCCOPY); } } else { tempBitmap->Create(FBitmapWidth, FBitmapHeight, 24); tempBitmap->CopyFromRect(FBitmap, FBitmapRange.left, FBitmapRange.top, SRCCOPY); if (FMask) { tempMask->Create(FBitmapWidth, FBitmapHeight, 1); tempMask->CopyFromRect(FMask, FBitmapRange.left, FBitmapRange.top, SRCCOPY); } } if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ dstBitmap->UnionStretchBltYreverse( FBitmapRange.right, FBitmapRange.top, FBitmapWidth, FBitmapHeight, tempBitmap, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); if (FMask) dstMask->UnionStretchBltYreverse( FBitmapRange.right, FBitmapRange.top, FBitmapWidth, FBitmapHeight, tempMask, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); } else { dstBitmap->UnionStretchBltYreverse( FBitmapRange.left - FBitmapWidth, FBitmapRange.top, FBitmapWidth, FBitmapHeight, tempBitmap, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); if (FMask) dstMask->UnionStretchBltYreverse( FBitmapRange.left - FBitmapWidth, FBitmapRange.top, FBitmapWidth, FBitmapHeight, tempMask, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); } } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ dstBitmap->UnionStretchBltXreverse( FBitmapRange.left, FBitmapRange.top + FBitmapHeight, FBitmapWidth, FBitmapHeight, tempBitmap, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); if (FMask) dstMask->UnionStretchBltXreverse( FBitmapRange.left, FBitmapRange.top + FBitmapHeight, FBitmapWidth, FBitmapHeight, tempMask, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); } else { dstBitmap->UnionStretchBltXreverse( FBitmapRange.left, FBitmapRange.top - FBitmapHeight, FBitmapWidth, FBitmapHeight, tempBitmap, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); if (FMask) dstMask->UnionStretchBltXreverse( FBitmapRange.left, FBitmapRange.top - FBitmapHeight, FBitmapWidth, FBitmapHeight, tempMask, 0, 0, FBitmapWidth, FBitmapHeight, SRCCOPY); } } if (tempBitmap) delete tempBitmap; if (tempMask) delete tempMask; // dstBitmap->CopyToRect(FDstRange.left, FDstRange.top, ApplyBitmap, SRCCOPY); // if (Mask) Mask->CopyToRect(FDstRange.left, FDstRange.top, ApplyMask, SRCCOPY); } //--------------------------------------------------------------------------- void __fastcall TReflection::ApplyMerge(TUnionBitmap *dstBitmap, TUnionBitmap *dstMask) { TUnionBitmap *ApplyBitmap = NULL; TUnionBitmap *ApplyMask = NULL; ApplyBitmap = new TUnionBitmap; if (FMask) ApplyMask = new TUnionBitmap; MakeApplyBitmap(ApplyBitmap, ApplyMask); if (ApplyBitmap->BitsPerPixel == 8){ dstBitmap->Create(ApplyBitmap->Width, ApplyBitmap->Height, 8, FRgb); dstMask->Create(ApplyBitmap->Width, ApplyBitmap->Height, 8, FRgb); dstMask->FillRect(Rect(0, 0, ApplyBitmap->Width, ApplyBitmap->Height), 0); } else { dstBitmap->Create(ApplyBitmap->Width, ApplyBitmap->Height, 24); dstMask->Create(ApplyBitmap->Width, ApplyBitmap->Height, 1); dstMask->FillRect(Rect(0, 0, ApplyBitmap->Width, ApplyBitmap->Height), clBlack); } dstBitmap->Copy(ApplyBitmap, SRCCOPY); if (FMask){ dstMask->Copy(ApplyMask, SRCCOPY); } if (ApplyBitmap) delete ApplyBitmap; if (ApplyMask) delete ApplyMask; } //--------------------------------------------------------------------------- void __fastcall TReflection::ReflectionGridPaint(HDC dcMemV, RECT Range, int PositionX, int PositionY, double dZoom) { double gx, gy, gzx, gzy, p; HPEN hPen = NULL, hOldPen = NULL; int vw, vh; int GridMark = 1; gx = Range.right - Range.left; gy = Range.bottom - Range.top; vw = (Range.right - Range.left)*dZoom; vh = (Range.bottom - Range.top)*dZoom; gzx = gx*dZoom; gzy = gy*dZoom; SetROP2(dcMemV, R2_COPYPEN); if ((hPen = CreatePen(psDashDot, 1, clBlack)) == NULL) goto fail; hOldPen = (HPEN)SelectObject(dcMemV, hPen); if (FDirection == D_LR){ p = gx + PositionX-Floor(PositionX/gx)*gx; p = p>0 ? (gx+gx-p)*dZoom : 0; MoveToEx(dcMemV, p, 0, NULL); LineTo(dcMemV, p, vh); } else if (FDirection == D_TB){ p = gy + PositionY-Floor(PositionY/gy)*gy; p = p>0 ? (gy+gy-p)*dZoom : 0; MoveToEx(dcMemV, 0, p, NULL); LineTo(dcMemV, vw, p); } SelectObject(dcMemV, hOldPen); hOldPen = NULL; DeleteObject(hPen); hPen = NULL; return; fail: if (hPen) { if (hOldPen) SelectObject(dcMemV, hOldPen); DeleteObject(hPen); } return; } //--------------------------------------------------------------------------- POINT __fastcall TReflection::FindOriginalPos(int x, int y) { POINT rtn; rtn.x = -1; rtn.y = -1; if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ if (x <= FBitmapWidth) rtn.x = x + FBitmapRange.left; else rtn.x = FBitmapWidth - x; if (y <= FBitmapHeight) rtn.y = y + FBitmapRange.top; else rtn.y = FBitmapHeight - y; } else if (FWorkSide == D_RIGHT){ if (x >= FBitmapWidth) rtn.x = x + FBitmapRange.left - FBitmapWidth; else rtn.x = x - FBitmapWidth; if (y <= FBitmapHeight) rtn.y = y + FBitmapRange.top; else rtn.y = FBitmapHeight - y; } } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ if (x <= FBitmapWidth) rtn.x = x + FBitmapRange.left; else rtn.x = FBitmapWidth - x; if (y <= FBitmapHeight) rtn.y = y + FBitmapRange.top; else rtn.y = FBitmapHeight - y; } else if (FWorkSide == D_BOTTOM){ if (x <= FBitmapWidth) rtn.x = x + FBitmapRange.left; else rtn.x = FBitmapWidth - x; if (y >= FBitmapHeight) rtn.y = y + FBitmapRange.top - FBitmapHeight; else rtn.y = y - FBitmapHeight; } } /* if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ if (x <= FBitmapWidth){ rtn.x = (FBitmapWidth - x) + FBitmapRange.left; rtn.y = y + FBitmapRange.top; } else { rtn.x = FBitmapWidth - x; //-1; rtn.y = y + FBitmapRange.top; } } else if (FWorkSide == D_RIGHT){ if (x >= FBitmapWidth){ rtn.x = x + (FBitmapRange.left - FBitmapWidth); rtn.y = y + FBitmapRange.top; } else { rtn.x = x - FBitmapWidth; //-1; rtn.y = y + FBitmapRange.top; } } } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ if (y <= FBitmapHeight){ rtn.x = x + FBitmapRange.left; rtn.y = (FBitmapHeight - y) + FBitmapRange.top; } else { rtn.x = x + FBitmapRange.left; rtn.y = FBitmapHeight - y; //-1; } } else if (FWorkSide == D_BOTTOM){ if (y >= FBitmapHeight){ rtn.x = x + FBitmapRange.left; rtn.y = y + (FBitmapRange.top - FBitmapHeight); } else { rtn.x = x + FBitmapRange.left; rtn.y = y - FBitmapHeight; //-1; } } } */ return rtn; } //--------------------------------------------------------------------------- POINT __fastcall TReflection::FindScreenReflectionPos(int screenx, int screeny) { // screenx, screeny´Â workside¿¡¼­ÀÇ È­¸é»ó ÁÂÇ¥ÀÓ POINT rtn; if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ rtn.x = (FBitmapWidth - screenx) + FBitmapWidth; } else { rtn.x = FBitmapWidth - (screenx - FBitmapWidth); } rtn.y = screeny; } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ rtn.y = (FBitmapHeight - screeny) + FBitmapHeight; } else { rtn.y = FBitmapHeight - (screeny - FBitmapHeight); } rtn.x = screenx; } return rtn; } //--------------------------------------------------------------------------- bool __fastcall TReflection::ChangeRectPaintRange(RECT rt, RECT &rtnRect) { bool rtn = true; if (FDirection == D_LR){ if (FWorkSide == D_LEFT){ if (rt.left >= FBitmapWidth) rtn = false; else { rtnRect.left = rt.left; rtnRect.top = rt.top; if (rt.right > FBitmapWidth) rtnRect.right = FBitmapWidth; else rtnRect.right = rt.right; rtnRect.bottom = rt.bottom; } } else { if (rt.right < FBitmapWidth) rtn = false; else { if (rt.left < FBitmapWidth) rtnRect.left = FBitmapWidth; else rtnRect.left = rt.left; rtnRect.top = rt.top; rtnRect.right = rt.right; rtnRect.bottom = rt.bottom; } } } else if (FDirection == D_TB){ if (FWorkSide == D_TOP){ if (rt.top >= FBitmapHeight) rtn = false; else { rtnRect.left = rt.left; rtnRect.top = rt.top; rtnRect.right = rt.right; if (rt.bottom > FBitmapHeight) rtnRect.bottom = FBitmapHeight; else rtnRect.bottom = rt.bottom; } } else { if (rt.bottom < FBitmapHeight) rtn = false; else { rtnRect.left = rt.left; if (rt.top < FBitmapHeight) rtnRect.top = FBitmapHeight; else rtnRect.top = rt.top; rtnRect.right = rt.right; rtnRect.bottom = rt.bottom; } } } return rtn; } //--------------------------------------------------------------------------- POINT __fastcall TReflection::ChangeAvailableOriginalRange(RECT rc, RECT &rtnRange) { POINT pts, pte; pts = FindOriginalPos(rc.left, rc.top); pte = FindOriginalPos(rc.right, rc.bottom); int psx = pts.x, psy = pts.y, pex = pte.x, pey = pte.y; int addx = 0, addy = 0; if (FDirection == D_LR) { if (FWorkSide == D_LEFT) { if (psx < 0) { addx -= psx; psx = FBitmapRange.left; } if (pex < 0) { pex = FBitmapRange.right; } else if (pex > FBitmapRange.right) { pex = FBitmapRange.right; } if (psy < 0) { addy -= psy; psy = FBitmapRange.top; } if (pey < 0) { pey = FBitmapRange.bottom; } else if (pey > FBitmapRange.bottom) { pey = FBitmapRange.bottom; } } else { if (psx < 0) { addx -= psx; psx = FBitmapRange.left; } if (pex > FBitmapRange.right) { pex = FBitmapRange.right; } if (psy < 0) { addy -= psy; psy = FBitmapRange.top; } if (pey < 0) { pey = FBitmapRange.bottom; } else if (pey > FBitmapRange.bottom) { pey = FBitmapRange.bottom; } } } else { if (FWorkSide == D_TOP) { if (psx < 0) { addx -= psx; psx = FBitmapRange.left; } if (pex < 0) { pex = FBitmapRange.right; } else if (pex > FBitmapRange.right) { pex = FBitmapRange.right; } if (psy < 0) { addy -= psy; psy = FBitmapRange.top; } if (pey < 0) { pey = FBitmapRange.bottom; } else if (pey > FBitmapRange.bottom) { pey = FBitmapRange.bottom; } } else { if (pex < 0) { pex = FBitmapRange.right; } else if (pex > FBitmapRange.right) { pex = FBitmapRange.right; } if (psy < 0) { addy -= psy; psy = FBitmapRange.top; } if (pey < 0) { pey = FBitmapRange.bottom; } else if (pey > FBitmapRange.bottom) { pey = FBitmapRange.bottom; } } } rtnRange.left = psx > pex ? pex : psx; //min(psx, pex); rtnRange.top = psy > pey ? pey : psy; //min(psy, pey); rtnRange.right = psx < pex ? pex : psx; //max(psx, pex); rtnRange.bottom = psx < pex ? pey : psy; //max(psy, pey); return Point(addx, addy); } //--------------------------------------------------------------------------- void __fastcall TReflection::ChangeAvailableScreenRange(RECT rc, RECT &rtnRange) { rtnRange.left = rc.left; rtnRange.top = rc.top; rtnRange.right = rc.right; rtnRange.bottom = rc.bottom; if (FDirection == D_LR) { if (FWorkSide == D_LEFT) { if (rc.left > FBitmapWidth) rtnRange.left = FBitmapWidth; if (rc.top < 0) rtnRange.top = 0; if (rc.right > FBitmapWidth) rtnRange.right = FBitmapWidth; if (rc.bottom > FBitmapHeight) rtnRange.bottom = FBitmapHeight; } else { if (rc.left <= FBitmapWidth) rtnRange.left = FBitmapWidth; if (rc.top < 0) rtnRange.top = 0; if (rc.right >= FBitmapWidth * 2) rtnRange.right = FBitmapWidth * 2; if (rc.bottom >= FBitmapHeight) rtnRange.bottom = FBitmapHeight; } } else { if (FWorkSide == D_TOP) { if (rc.left < 0) rtnRange.left = 0; if (rc.top < 0) rtnRange.top = 0; if (rc.right > FBitmapWidth) rtnRange.right = FBitmapWidth; if (rc.bottom > FBitmapHeight) rtnRange.bottom = FBitmapHeight; } else { if (rc.left < 0) rtnRange.left = 0; if (rc.top < FBitmapHeight) rtnRange.top = FBitmapHeight; if (rc.right > FBitmapWidth) rtnRange.right = FBitmapWidth; if (rc.bottom > FBitmapHeight * 2) rtnRange.bottom = FBitmapHeight * 2; } } } //---------------------------------------------------------------------------