#include #include #include #include #include /* #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include */ //char ImageView::szClassName[]="GIFView"; //char ImageView::szMenuName[]=""; //HINSTANCE ImageView::smhInstance=0; ImageView::ImageView() /* : mhClientWindow(0), mhFrameWindow(0), mIsDestroyed(0), mMaxColors(0), mWidth(0), mHeight(0), mhPalette(0), mhGlobalInvert(0), mhGlobal(0), mhBMPGlobal(0), mpStatusBar(0), mpProcessImage(0), mpBI(0), mhpImageInvert(0), mhpImage(0), mhSystemMenu(0), mhFrameMenu(0), mhViewMenu(0), mpSpacial(0), mpPerspectiveWarp(0), mlpClipboard(0), mlpToolBar(0), mlpGridMesh(0), mlpConvexTransform(0), mToolbarVisibility(TRUE), mCurrentMeshFrames(DefaultFrames) */ : mCurrentMeshFrames(DefaultFrames) { mBkBrush.createHatchBrush(Brush::HDiagCross,RGBColor(128,128,128)); mPaintHandler.setCallback(this,&ImageView::paintHandler); mCreateHandler.setCallback(this,&ImageView::createHandler); mSizeHandler.setCallback(this,&ImageView::sizeHandler); mVerticalScrollHandler.setCallback(this,&ImageView::verticalScrollHandler); mHorizontalScrollHandler.setCallback(this,&ImageView::horizontalScrollHandler); mEraseBackgroundHandler.setCallback(this,&ImageView::eraseBackgroundHandler); installHandlers(); // mPathFileName[0]=0; } ImageView::ImageView(const ImageView &/*someImageView*/) : mCurrentMeshFrames(DefaultFrames) /*: mhClientWindow(0), mhFrameWindow(0), mIsDestroyed(0), mMaxColors(0), mWidth(0), mHeight(0), mhPalette(0), mhGlobalInvert(0), mhGlobal(0), mhBMPGlobal(0), mpStatusBar(0), mpProcessImage(0), mpBI(0), mhpImageInvert(0), mhpImage(0), mhSystemMenu(0), mhFrameMenu(0), mhViewMenu(0), mpSpacial(0), mpPerspectiveWarp(0), mlpClipboard(0), mlpToolBar(0), mlpGridMesh(0), mlpConvexTransform(0), mToolbarVisibility(TRUE), mCurrentMeshFrames(DefaultFrames) */ { mBkBrush.createHatchBrush(Brush::HDiagCross,RGBColor(128,128,128)); mPaintHandler.setCallback(this,&ImageView::paintHandler); mCreateHandler.setCallback(this,&ImageView::createHandler); mSizeHandler.setCallback(this,&ImageView::sizeHandler); mVerticalScrollHandler.setCallback(this,&ImageView::verticalScrollHandler); mHorizontalScrollHandler.setCallback(this,&ImageView::horizontalScrollHandler); mEraseBackgroundHandler.setCallback(this,&ImageView::eraseBackgroundHandler); installHandlers(); } ImageView::~ImageView() { removeHandlers(); /* if(mhPalette)::DeleteObject(mhPalette); if(mhGlobalInvert) { ::GlobalUnlock(mhGlobalInvert); ::GlobalFree(mhGlobalInvert); } if(mhBMPGlobal) { ::GlobalUnlock(mhBMPGlobal); ::GlobalFree(mhBMPGlobal); } if(mhViewMenu)::DestroyMenu(mhViewMenu); if(!mIsDestroyed && GetHandle()) ::SendMessage(mhClientWindow,WM_MDIDESTROY,(WPARAM)GetHandle(),0L); if(mlpToolBar)delete mlpToolBar; if(mlpGridMesh)delete mlpGridMesh; */ } void ImageView::installHandlers() { insertHandler(VectorHandler::PaintHandler,&mPaintHandler); insertHandler(VectorHandler::SizeHandler,&mSizeHandler); insertHandler(VectorHandler::CreateHandler,&mCreateHandler); insertHandler(VectorHandler::VerticalScrollHandler,&mVerticalScrollHandler); insertHandler(VectorHandler::HorizontalScrollHandler,&mHorizontalScrollHandler); insertHandler(VectorHandler::EraseBackgroundHandler,&mHorizontalScrollHandler); } void ImageView::removeHandlers() { removeHandler(VectorHandler::PaintHandler,&mPaintHandler); removeHandler(VectorHandler::SizeHandler,&mSizeHandler); removeHandler(VectorHandler::CreateHandler,&mCreateHandler); removeHandler(VectorHandler::VerticalScrollHandler,&mVerticalScrollHandler); removeHandler(VectorHandler::HorizontalScrollHandler,&mHorizontalScrollHandler); removeHandler(VectorHandler::EraseBackgroundHandler,&mHorizontalScrollHandler); } CallbackData::ReturnType ImageView::createHandler(CallbackData &callbackData) { mScrollInfo.hwndOwner(*this); return FALSE; } CallbackData::ReturnType ImageView::sizeHandler(CallbackData &callbackData) { mScrollInfo.handleSize(callbackData); return FALSE; } CallbackData::ReturnType ImageView::horizontalScrollHandler(CallbackData &callbackData) { mScrollInfo.handleHorizontalScroll(callbackData); return (CallbackData::ReturnType)FALSE; } CallbackData::ReturnType ImageView::verticalScrollHandler(CallbackData &callbackData) { mScrollInfo.handleVerticalScroll(callbackData); return (CallbackData::ReturnType)FALSE; } CallbackData::ReturnType ImageView::eraseBackgroundHandler(CallbackData &callbackData) { return TRUE; } CallbackData::ReturnType ImageView::paintHandler(CallbackData &callbackData) { PaintInformation &paintInfo=*((PaintInformation*)callbackData.lParam()); PureDevice &paintDevice=(PureDevice&)paintInfo; clearEmptyRegion(paintDevice); if(mScrollInfo.sizeEvent()) { mScrollInfo.sizeEvent(FALSE); mImage.draw(paintDevice,Rect(0,0,mImage.width(),mImage.height()),Point(mScrollInfo.currScrollx(),mScrollInfo.currScrolly())); } if(mScrollInfo.scrollEvent()||(!mScrollInfo.sizeEvent()&&!mScrollInfo.scrollEvent())) { Rect paintRect(paintInfo.paintRect()); mScrollInfo.scrollEvent(FALSE); paintRect.right(paintRect.right()-paintRect.left()); paintRect.bottom(paintRect.bottom()-paintRect.top()); mImage.draw(paintDevice,paintRect,Point(paintRect.left()+mScrollInfo.currScrollx(),paintRect.top()+mScrollInfo.currScrolly())); } return (CallbackData::ReturnType)FALSE; } void ImageView::clearEmptyRegion(PureDevice &pureDevice) { Rect imgRect; Rect winRect; Rect rtRect; Rect btRect; imgRect.right(mImage.width()); imgRect.bottom(mImage.height()); clientRect(winRect); rtRect.left(winRect.right()>imgRect.right()?imgRect.right():winRect.right()); rtRect.right(winRect.right()>imgRect.right()?winRect.right():imgRect.right()); rtRect.bottom(winRect.bottom()>imgRect.bottom()?winRect.bottom():imgRect.bottom()); btRect.top(imgRect.bottom()); btRect.right(rtRect.left()); btRect.bottom(winRect.bottom()); pureDevice.fillRect(rtRect,mBkBrush); pureDevice.fillRect(btRect,mBkBrush); } bool ImageView::open(const String &strPathFileName) { if(!mImage.open(strPathFileName,*this)){destroy();return false;} mScrollInfo.scrollableObjectDimensions(mImage.width(),mImage.height()); show(SW_SHOW); setTitle(strPathFileName); invalidate(false); setFocus(); return true; } void ImageView::operator=(Bitmap &someBitmap) { /* RGBQUAD FAR *pRGBQuad; RGBStruct rgbStruct; DWORD sizeBitmapInfo; DWORD sizeImage; HGLOBAL hGlobalSourceBitmapInfo; HGLOBAL hGlobalSourceImage; BITMAPINFO FAR *lpSourceBitmapInfo; UHUGE *lpSourceImage; hGlobalSourceBitmapInfo=someBitmap.lockedBitmapInfo(); #if defined(__FLAT__) sizeBitmapInfo=::GlobalSize(hGlobalSourceBitmapInfo); #else sizeBitmapInfo=::GetSelectorLimit((UINT)hGlobalSourceBitmapInfo)+1L; #endif mhBMPGlobal=::GlobalAlloc(GMEM_FIXED,sizeBitmapInfo); mpBI=(BITMAPINFO FAR *)::GlobalLock(mhBMPGlobal); lpSourceBitmapInfo=(BITMAPINFO *)::GlobalLock(hGlobalSourceBitmapInfo); Main::hmemcpy((UHUGE *)mpBI,(UHUGE *)lpSourceBitmapInfo,sizeBitmapInfo); ::GlobalUnlock(hGlobalSourceBitmapInfo); sizeImage=((((mpBI->bmiHeader.biWidth* mpBI->bmiHeader.biBitCount)+31)&~31)>>3)* mpBI->bmiHeader.biHeight; mhGlobalInvert=::GlobalAlloc(GMEM_FIXED,sizeImage); mhpImageInvert=(UHUGE*)::GlobalLock(mhGlobalInvert); hGlobalSourceImage=someBitmap.lockedImageData(); lpSourceImage=(UHUGE*)::GlobalLock(hGlobalSourceImage); Main::hmemcpy(mhpImageInvert,lpSourceImage,sizeImage); ::GlobalUnlock(hGlobalSourceImage); mWidth=(WORD)mpBI->bmiHeader.biWidth; mHeight=(WORD)mpBI->bmiHeader.biHeight; if(!(mMaxColors=(WORD)mpBI->bmiHeader.biClrUsed)) mMaxColors=1 << mpBI->bmiHeader.biBitCount; for(int i=0;ibmiColors[i]; rgbStruct.Red(pRGBQuad->rgbRed); rgbStruct.Green(pRGBQuad->rgbGreen); rgbStruct.Blue(pRGBQuad->rgbBlue); mPaletteData.insert(&rgbStruct); } createPalette(); */ } /*void ImageView::Paint(void) { RECT rect; PAINTSTRUCT ps; HDC hDC; HPALETTE hOldPalette; HWND activeWindow; WORD menuState; WORD errorCount=0; ::GetClientRect(GetHandle(),(RECT FAR *)&rect); activeWindow=(HWND)LOWORD(::SendMessage(mhClientWindow,WM_MDIGETACTIVE,0,0L)); hDC=::BeginPaint(GetHandle(),&ps); if(GetHandle()==activeWindow)hOldPalette=::SelectPalette(hDC,mhPalette,FALSE); else hOldPalette=::SelectPalette(hDC,mhPalette,TRUE); ::RealizePalette(hDC); menuState=::GetMenuState(mhSystemMenu,MenuConform,MF_BYCOMMAND); if(!(menuState&MF_CHECKED)) ::StretchDIBits(hDC,0,0,rect.right,rect.bottom,0,0,mWidth,mHeight,mhpImageInvert,(BITMAPINFO *)mpBI,DIB_RGB_COLORS,SRCCOPY); else { while(!::StretchDIBits(hDC,0,0,mWidth,mHeight,0,0,mWidth,mHeight,mhpImageInvert,(BITMAPINFO *)mpBI,DIB_RGB_COLORS,SRCCOPY)) { errorCount++; ::MessageBeep(0); mWidth--; mHeight--; if((int)mWidth-1<0 || (int)mHeight-1<0)break; ::GlobalUnlock(mhGlobalInvert); Resize resizeImage(mWidth+1,mHeight+1,mWidth,mHeight,mhGlobalInvert); HGLOBAL hGlobalTemp=resizeImage.resizeImage(); ::GlobalFree(mhGlobalInvert); mhGlobalInvert=hGlobalTemp; mhpImageInvert=(UHUGE *)::GlobalLock(hGlobalTemp); mpBI->bmiHeader.biWidth=mWidth; mpBI->bmiHeader.biHeight=mHeight; } if(errorCount)updateCaption(); } if(GetHandle()==activeWindow)::SelectPalette(hDC,hOldPalette,FALSE); else ::SelectPalette(hDC,hOldPalette,TRUE); ::EndPaint(GetHandle(),&ps); if(mlpGridMesh)mlpGridMesh->suspendMesh(FALSE); } */ void ImageView::updateCaption(void)const { /* char Buffer[MaxFileName]; char *ptr; ::GetWindowText(GetHandle(),(LPSTR)Buffer,sizeof(Buffer)); ptr=Buffer+::strlen(Buffer)-1; while(*ptr!='-')ptr--; ptr+=2; ::sprintf(ptr,"%dx%dx%d",mWidth,mHeight,mMaxColors); ::SetWindowText(GetHandle(),(LPSTR)Buffer); */ } void ImageView::modifySystemMenu(void) { /* if(mhSystemMenu)return; mhSystemMenu=::GetSystemMenu(GetHandle(),FALSE); ::AppendMenu(mhSystemMenu,MF_SEPARATOR,0,0); ::AppendMenu(mhSystemMenu,MF_STRING|MF_CHECKED,MenuConform,(LPSTR)"Non-Conforming"); ::DrawMenuBar(GetHandle()); */ } void ImageView::handleDestroyEvent() { /* if(mpProcessImage)mpProcessImage->cancelThread(); if(mpSpacial)mpSpacial->cancelThread(); if(mpPerspectiveWarp)mpPerspectiveWarp->cancelThread(); if(mlpConvexTransform)mlpConvexTransform->cancelThread(); if(mlpClipboard)delete mlpClipboard; mIsDestroyed=TRUE; */ return; } void ImageView::handleActivateEvent(WPARAM wParam,LPARAM /*lParam*/) { /* if(wParam) { if(mlpGridMesh)mlpGridMesh->suspendMesh(TRUE); HDC inhDC(::GetDC(GetHandle())); ::SelectPalette(inhDC,mhPalette,FALSE); ::SendMessage(mhFrameWindow,WM_COMMAND,IDM_INVALIDATEMDIWINDOWS,MAKELPARAM(0,0)); if(::RealizePalette(inhDC)>0)::InvalidateRect(GetHandle(),0,TRUE); ::ReleaseDC(GetHandle(),inhDC); #if defined(__FLAT__) ::SendMessage(mhClientWindow,WM_MDISETMENU,(WPARAM)mhViewMenu,(LPARAM)::GetSubMenu(mhViewMenu,0)); #else ::SendMessage(mhClientWindow,WM_MDISETMENU,FALSE,MAKELONG(mhViewMenu,::GetSubMenu(mhViewMenu,0))); #endif if(mToolbarVisibility&&mlpToolBar&&!mlpToolBar->isVisible())mlpToolBar->showWindow(); } else { if(mlpToolBar&&mlpToolBar->isVisible())mlpToolBar->showWindow(FALSE); if(mlpGridMesh)mlpGridMesh->showWindow(TRUE); #if defined(__FLAT__) ::SendMessage(mhClientWindow,WM_MDISETMENU,(WPARAM)mhFrameMenu,(LPARAM)0); #else ::SendMessage(mhClientWindow,WM_MDISETMENU,FALSE,MAKELONG(mhFrameMenu,0)); #endif } ::DrawMenuBar(mhFrameWindow); */ return; } /* long ImageView::WndProc(UINT message,WPARAM wParam,LPARAM lParam) { switch(message) { case WM_CREATE : { char buffer[100]; mlpClipboard=new Clipboard(GetHandle()); assert(0!=mlpClipboard); ::SetWindowText(GetHandle(),(LPSTR)mPathFileName); ::sprintf(buffer,"%s - %dx%dx%d",mPathFileName,mWidth,mHeight,mMaxColors); ::SetWindowText(GetHandle(),(LPSTR)buffer); modifySystemMenu(); mCapture=GetHandle(); ::EnableMenuItem(mhViewMenu,MENU_PASTE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); } return FALSE; case WM_CHANGECBCHAIN : if(!mlpClipboard)break; mlpClipboard->changeClipboardChain(message,wParam,lParam); return FALSE; case WM_DRAWCLIPBOARD : if(!mlpClipboard)break; if(mlpClipboard->drawClipboard(message,wParam,lParam)) ::EnableMenuItem(mhViewMenu,MENU_PASTE,MF_BYCOMMAND|MF_ENABLED); return FALSE; case WM_LBUTTONDOWN : mCapture.leftButtonDown(lParam); return FALSE; case WM_MOUSEMOVE : mCapture.mouseMove(lParam); return FALSE; case WM_LBUTTONUP : mCapture.leftButtonUp(); return FALSE; case WM_PAINT : Paint(); return FALSE; case WM_MDIACTIVATE : #if defined(__FLAT__) handleActivateEvent((WPARAM)lParam,(LPARAM)wParam); #else handleActivateEvent(wParam,lParam); #endif return FALSE; case WM_QUERYENDSESSION : break; case WM_DESTROY : handleDestroyEvent(); return FALSE; case WM_SYSCOMMAND : handleSystemMenuEvent(wParam); break; case WM_COMMAND : switch(GET_WM_COMMAND_ID(wParam,lParam)) { case MenuConform : ::SendMessage(GetHandle(),WM_SYSCOMMAND,MenuConform,0L); return FALSE; case MENU_SMOOTHING : imageProcessing(); return FALSE; case MENU_RESIZE : resizeImage(); return FALSE; case MENU_TRANSLATE : translateMatrix(); return FALSE; case MENU_SHEAR : shearTransform(); return FALSE; case MENU_WARP_PERSPECTIVE : warpPerspective(); return FALSE; case MENU_WARP_CONVEX : warpConvex(); return FALSE; case MENU_CLIP : menuClip(); return FALSE; case MENU_DISSOLVE : { AdjustDissolve adjustDissolve(GetHandle()); adjustDissolve.adjustDissolve(mDissolveSchedule,mCurrentMeshFrames); } return FALSE; case MENU_TBSIGMA : { FrameDialog frameDialog(GetHandle()); frameDialog.performFrameDialog(mCurrentMeshFrames); } return FALSE; case MENU_TBLOAD : case MENU_TBSAVE : case MENU_TBTRANSFORMB : case MENU_TBTRANSFORMA : case IDM_WINLIST : handleMeshRequest(wParam,lParam); return FALSE; case MENU_TBCLIP : mCapture.reset(); if(mlpGridMesh) { delete mlpGridMesh; mlpGridMesh=0; } return FALSE; case MENU_TBMESH : if(!mlpGridMesh)mlpGridMesh=new GridMesh(GetHandle(),mWidth,mHeight); else mlpGridMesh->newMesh(mlpGridMesh->gridLines()+2); return FALSE; case MENU_FILE_SAVEBITMAP : saveBitmap(); return FALSE; case MENU_PALETTE_VIEW : { PaletteDialog viewPalette(GetHandle(),mhPalette); viewPalette.showPalette(); return FALSE; } case IDM_TOOLBAR : handleToolbarToggle(); break; default : return FALSE; } } return ::DefMDIChildProc(GetHandle(),message,wParam,lParam); } */ // ************************************************************** void ImageView::handleToolbarToggle(void) { /* String showToolbarString(STRING_SHOWTOOLBAR,Main::processInstance()); String hideToolbarString(STRING_HIDETOOLBAR,Main::processInstance()); String menuString; ::GetMenuString(mhViewMenu,IDM_TOOLBAR,menuString,String::MaxString,MF_BYCOMMAND); if(showToolbarString==menuString) { ::ModifyMenu(mhViewMenu,IDM_TOOLBAR,MF_STRING|MF_ENABLED,IDM_TOOLBAR,(LPSTR)hideToolbarString); mlpToolBar->showWindow(TRUE); mToolbarVisibility=TRUE; } else { ::ModifyMenu(mhViewMenu,IDM_TOOLBAR,MF_STRING|MF_ENABLED,IDM_TOOLBAR,(LPSTR)showToolbarString); mlpToolBar->showWindow(FALSE); mToolbarVisibility=FALSE; } ::DrawMenuBar(GetHandle()); */ } void ImageView::handleMeshRequest(WPARAM wParam,LPARAM lParam) { /* String meshFileName(mPathFileName); String meshPathFileName; IniFile iniSettings; iniSettings.makeFileName(meshFileName); meshFileName.token(".\0"); meshFileName+=".MSH"; meshPathFileName=iniSettings.meshDirectory(); meshPathFileName+=meshFileName; switch(wParam) { case MENU_TBLOAD : if(!mlpGridMesh)mlpGridMesh=new GridMesh(GetHandle(),mWidth,mHeight,GridMesh::NoShow); mlpGridMesh->loadMesh(meshPathFileName); break; case MENU_TBTRANSFORMA : if(!mlpGridMesh){::MessageBeep(0);break;} meshWarp(); break; case MENU_TBTRANSFORMB : if(!mlpGridMesh){::MessageBeep(0);break;} ::PostMessage(mhFrameWindow,WM_COMMAND,IDM_GETWINLIST,MAKELPARAM(GetHandle(),0)); break; case IDM_WINLIST : { WORD itemIndex; Block *lpViewBlock=(Block*)(lParam); if(!lpViewBlock||!lpViewBlock->size()){::MessageBeep(0);break;} ViewSelect selectView(GetHandle()); if(selectView.selectView(*lpViewBlock,itemIndex,mWidth,mHeight))meshWarp((*lpViewBlock)[itemIndex].windowPtr()); delete lpViewBlock; } break; case MENU_TBSAVE : if(!mlpGridMesh)break; mlpGridMesh->saveMesh(meshPathFileName); break; } */ return; } void ImageView::handleSystemMenuEvent(WPARAM wParam)const { /* WORD menuState; switch(wParam) { case MenuConform : menuState=::GetMenuState(mhSystemMenu,MenuConform,MF_BYCOMMAND); ::CheckMenuItem(mhSystemMenu,MenuConform,MF_BYCOMMAND | (menuState&MF_CHECKED?MF_UNCHECKED:MF_CHECKED)); ::DrawMenuBar(GetHandle()); ::InvalidateRect(GetHandle(),NULL,TRUE); } */ } void ImageView::enableMenu(const char isEnabled)const { /* if(isEnabled) { ::EnableMenuItem(mhViewMenu,MENU_CUT,MF_BYCOMMAND|MF_ENABLED); ::EnableMenuItem(mhViewMenu,MENU_COPY,MF_BYCOMMAND|MF_ENABLED); ::EnableMenuItem(mhViewMenu,MENU_PASTE,MF_BYCOMMAND|MF_ENABLED); ::EnableMenuItem(mhViewMenu,MENU_SMOOTHING,MF_BYCOMMAND|MF_ENABLED); ::EnableMenuItem(mhViewMenu,MENU_RESIZE,MF_BYCOMMAND|MF_ENABLED); ::EnableMenuItem(mhViewMenu,MENU_TRANSLATE,MF_BYCOMMAND|MF_ENABLED); ::EnableMenuItem(mhViewMenu,MENU_WARP_PERSPECTIVE,MF_BYCOMMAND|MF_ENABLED); ::EnableMenuItem(mhViewMenu,MENU_FILE_SAVEBITMAP,MF_BYCOMMAND|MF_ENABLED); } else { ::EnableMenuItem(mhViewMenu,MENU_CUT,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); ::EnableMenuItem(mhViewMenu,MENU_COPY,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); ::EnableMenuItem(mhViewMenu,MENU_PASTE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); ::EnableMenuItem(mhViewMenu,MENU_SMOOTHING,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); ::EnableMenuItem(mhViewMenu,MENU_RESIZE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); ::EnableMenuItem(mhViewMenu,MENU_TRANSLATE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); ::EnableMenuItem(mhViewMenu,MENU_WARP_PERSPECTIVE,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); ::EnableMenuItem(mhViewMenu,MENU_FILE_SAVEBITMAP,MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); } */ } void ImageView::imageProcessing(void) { /* enableMenu(FALSE); mpProcessImage=new Process(mhPalette,mhpImageInvert,mWidth,mHeight); if(mpProcessImage->showProcess(GetHandle(),mPathFileName) && !mIsDestroyed) ::InvalidateRect(GetHandle(),NULL,TRUE); if(!mIsDestroyed)enableMenu(TRUE); delete mpProcessImage; mpProcessImage=0; */ } void ImageView::resizeImage(void) { double sizeFactor; Factor resizeFactor(*this,"Resize Factor"); if(!resizeFactor.showFactor(sizeFactor,sizeFactor)||0.00==sizeFactor)return; /* HGLOBAL hGlobal; double sizeFactor; Factor resizeFactor(GetHandle(),"Resize Factor"); if(!resizeFactor.showFactor(sizeFactor,sizeFactor)||!sizeFactor)return; enableMenu(FALSE); mpSpacial=new SpacialTransform(mhPalette,mhpImageInvert,mWidth,mHeight,sizeFactor); hGlobal=mpSpacial->resizeImage(); if(mpSpacial->isCancelled()) { delete mpSpacial; mpSpacial=0; return; } delete mpSpacial; mpSpacial=0; if(hGlobal) { mWidth*=(sizeFactor/100.00); mHeight*=(sizeFactor/100.00); ::GlobalUnlock(mhGlobalInvert); ::GlobalFree(mhGlobalInvert); mhGlobalInvert=hGlobal; mhpImageInvert=(UHUGE *)::GlobalLock(mhGlobalInvert); mpBI->bmiHeader.biWidth=mWidth; mpBI->bmiHeader.biHeight=mHeight; } ::InvalidateRect(GetHandle(),NULL,TRUE); enableMenu(TRUE); updateCaption(); */ } void ImageView::menuClip(void) { /* RECT copyRect; HGLOBAL hGlobalResizedImage; UHUGE *ptrResizedImage; if(!mCapture.hasRectangle())return; mCapture.boundedRect(copyRect); enableMenu(FALSE); ::GlobalUnlock(mhGlobalInvert); Resize resizeImage(mWidth,mHeight,copyRect,mhGlobalInvert); if(0!=(hGlobalResizedImage=resizeImage.resizeImage())) { ::GlobalFree(mhGlobalInvert); ptrResizedImage=(UHUGE *)::GlobalLock(hGlobalResizedImage); mhGlobalInvert=hGlobalResizedImage; mhpImageInvert=ptrResizedImage; mpBI->bmiHeader.biWidth=mWidth=(copyRect.right-copyRect.left)+1; mpBI->bmiHeader.biHeight=mHeight=(copyRect.bottom-copyRect.top)+1; ::InvalidateRect(GetHandle(),NULL,TRUE); } else ::GlobalLock(mhGlobalInvert); updateCaption(); enableMenu(TRUE); */ } void ImageView::saveBitmap(void) { /* char bitmapName[MaxFileName]; SelectFile selector(GetHandle(),SelectFile::Write); selector.SetFileSpec(String(STRING_ASTERISKDOTBMP,Main::processInstance())); if(selector.GetFileName(bitmapName,sizeof(bitmapName))) { waitCursor(TRUE); Bitmap bitmapImage(bitmapName,mhGlobalInvert,mhBMPGlobal); bitmapImage.saveBitmap(); waitCursor(FALSE); } */ } void ImageView::translateMatrix(void) { /* UHUGE *ptr; double xFactor; double yFactor; Factor resizeFactor(GetHandle(),"Translate Factor"); if(!resizeFactor.showFactor(yFactor,xFactor))return; if(!yFactor && !xFactor)return; enableMenu(FALSE); waitCursor(TRUE); yFactor*=-1; xFactor*=-1; HGLOBAL hGlobal=::GlobalAlloc(GMEM_FIXED,(LONG)mWidth*(LONG)mHeight); ptr=(UHUGE*)::GlobalLock(hGlobal); TranslationMatrix translation(mHeight,mWidth,(int)xFactor,(int)yFactor,&mhpImageInvert,&ptr); translation.performTranslation(); ::GlobalUnlock(mhGlobalInvert); ::GlobalFree(mhGlobalInvert); mhGlobalInvert=hGlobal; mhpImageInvert=ptr; ::InvalidateRect(GetHandle(),NULL,TRUE); waitCursor(FALSE); enableMenu(TRUE); */ } void ImageView::shearTransform(void) { /* HGLOBAL hGlobalTemp; WORD width(mWidth); WORD height(mHeight); double xFactor(0.3); double yFactor(0.00); Factor shearFactor(GetHandle(),"Shear Factors"); if(!shearFactor.showFactor(xFactor,yFactor))return; Shear shearTransform; hGlobalTemp=shearTransform.performShear (width,height,xFactor,yFactor,mhpImageInvert); if(hGlobalTemp) { ::GlobalUnlock(mhGlobalInvert); ::GlobalFree(mhGlobalInvert); mpBI->bmiHeader.biWidth=mWidth=width; mpBI->bmiHeader.biHeight=mHeight=height; mhGlobalInvert=hGlobalTemp; mhpImageInvert=(UHUGE*)::GlobalLock(hGlobalTemp); } ::InvalidateRect(GetHandle(),NULL,TRUE); */ } void ImageView::warpPerspective(void) { /* HGLOBAL hGlobalTemp; Factor::Operation widthOperation; Factor::Operation heightOperation; double widthIncremental; double heightIncremental; double wRow; double wCol; WORD isCancelled; Factor resizeFactor(GetHandle(),"Perpective Warp"); if(!resizeFactor.showFactor( wRow,wCol, widthIncremental,widthOperation, heightIncremental,heightOperation ))return; enableMenu(FALSE); if(Factor::None==widthOperation&&Factor::None==heightOperation) mpPerspectiveWarp=new PerspectiveWarp(mWidth,mHeight,mhpImageInvert,wRow,wCol); else mpPerspectiveWarp=new PerspectiveWarp(mWidth,mHeight,wRow,wCol, (PerspectiveWarp::Operation)widthOperation,widthIncremental, (PerspectiveWarp::Operation)heightOperation,heightIncremental,mhpImageInvert); hGlobalTemp=mpPerspectiveWarp->performPerspectiveWarp(); isCancelled=mpPerspectiveWarp->isCancelled(); delete mpPerspectiveWarp; mpPerspectiveWarp=0; enableMenu(TRUE); if(isCancelled)return; if(hGlobalTemp) { ::GlobalUnlock(mhGlobalInvert); ::GlobalFree(mhGlobalInvert); mhGlobalInvert=hGlobalTemp; mhpImageInvert=(UHUGE*)::GlobalLock(hGlobalTemp); } ::InvalidateRect(GetHandle(),NULL,TRUE); */ } void ImageView::handleWarpConvex(void) { Convex convex; Image image; mImage=convex.performConvex(mImage,*this); invalidate(false); /* HGLOBAL hGlobalTemp; WORD isCancelled; mlpConvexTransform=new Convex; hGlobalTemp=mlpConvexTransform->performConvex(mWidth,mHeight,mhpImageInvert); isCancelled=mlpConvexTransform->isCancelled(); delete mlpConvexTransform; mlpConvexTransform=0; if(isCancelled)return; if(hGlobalTemp) { ::GlobalUnlock(mhGlobalInvert); ::GlobalFree(mhGlobalInvert); mhGlobalInvert=hGlobalTemp; mhpImageInvert=(UHUGE*)::GlobalLock(hGlobalTemp); } ::InvalidateRect(GetHandle(),NULL,TRUE); */ } // ********************************************************************************* void ImageView::meshWarp(Direction warpDirection) { /* Vector sourcePairs; Vector destPairs; Vector meshFrames; Vector sourcePoints; Vector destPoints; Block intermediatePathFileNames; HGLOBAL hGlobalOriginal; UHUGE *lpOriginal; int originalWidth; int originalHeight; HGLOBAL hGlobalTemp(0); MeshFrames meshFrame; int newWidth; int newHeight; size_t size; mlpGridMesh->retrieveMesh(sourcePoints,destPoints); if((size=(int)sourcePoints.size())!=destPoints.size())return; sourcePairs.size(destPairs.size(size)); for(int i=0;irowCols(),newWidth,newHeight); ::GlobalUnlock(mhGlobalInvert); ::GlobalFree(mhGlobalInvert); if(!hGlobalTemp)break; mhGlobalInvert=hGlobalTemp; mhpImageInvert=(UHUGE*)::GlobalLock(hGlobalTemp); mpBI->bmiHeader.biWidth=mWidth=newWidth; mpBI->bmiHeader.biHeight=mHeight=newHeight; ::InvalidateRect(GetHandle(),NULL,TRUE); ::UpdateWindow(GetHandle()); Bitmap bitmapImage(intermediatePathFileNames[i+1],mhGlobalInvert,mhBMPGlobal); bitmapImage.saveBitmap(); } if(!hGlobalTemp) { String tempString; ::sprintf(tempString,"Warp failed at %d",i); ::MessageBox(GetHandle(),(LPSTR)tempString,(LPSTR)"WARP ERROR",MB_ICONASTERISK); mhGlobalInvert=hGlobalOriginal; mhpImageInvert=lpOriginal; mpBI->bmiHeader.biWidth=mWidth=originalWidth; mpBI->bmiHeader.biHeight=mHeight=originalHeight; } else { ::GlobalUnlock(hGlobalOriginal); ::GlobalFree(hGlobalOriginal); } if(WarpForward==warpDirection)createProjectFile(intermediatePathFileNames); ::InvalidateRect(GetHandle(),NULL,TRUE); mlpGridMesh->showWindow(); */ } void ImageView::meshWarp(ImageView *lpTargetView) { /* Block intermediateSrcImage; Block intermediateDstImage; CrossDissolve crossDissolve; WORD currentTargetFrames; meshWarp(); currentTargetFrames=lpTargetView->mCurrentMeshFrames; lpTargetView->mCurrentMeshFrames=mCurrentMeshFrames; lpTargetView->meshWarp(WarpReverse); sequentialNames(mPathFileName,intermediateSrcImage,mCurrentMeshFrames); lpTargetView->sequentialNames(lpTargetView->mPathFileName,intermediateDstImage,lpTargetView->mCurrentMeshFrames); if(mDissolveSchedule.size()) crossDissolve.crossDissolve(intermediateSrcImage,intermediateDstImage,mDissolveSchedule); else crossDissolve.crossDissolve(intermediateSrcImage,intermediateDstImage); lpTargetView->mCurrentMeshFrames=currentTargetFrames; */ } void ImageView::createProjectFile(Block &pathFileNames) { /* String projectIDString(STRING_PROJECTIDSTRING,Main::processInstance()); String projectExtension(STRING_PROJECTEXTENSION,Main::processInstance()); String carriageReturn(STRING_CRLF,Main::processInstance()); String dotString(STRING_DOT,Main::processInstance()); String fileNameString; size_t size((int)pathFileNames.size()); if(!size)return; fileNameString=pathFileNames[0]; fileNameString.token(dotString); fileNameString+=projectExtension; ofstream outputProject(fileNameString); if(!outputProject.fail()&&!outputProject.bad()) { outputProject << (LPSTR)projectIDString << (LPSTR)carriageReturn; for(int i=0;i &pathFileNames,int nFrames) { /* IniFile iniSettings; String currentExtension(STRING_MESHEXTENSION,Main::processInstance()); String dotString(STRING_DOT,Main::processInstance()); String tempString(pathFileName); String intermediatePathFileName; pathFileNames.remove(); iniSettings.makeFileName(tempString); intermediatePathFileName=iniSettings.projectDirectory(); intermediatePathFileName+=tempString; for(int i=0;inewMesh(mGridMesh->gridLines()+2); else { mGridMesh.destroy(); mGridMesh=::new GridMesh(*this,mImage.width(),mImage.height()); mGridMesh.disposition(PointerDisposition::Delete); mGridMesh->showWindow(); } } void ImageView::noMesh(void) { if(!mGridMesh.isOkay())return; mGridMesh.destroy(); } void ImageView::handleFrames(void) { FrameDialog frameDialog(*this); frameDialog.perform(mCurrentMeshFrames); } // ***** virtual overloads void ImageView::preRegister(WNDCLASS &wndClass) { wndClass.style|=CS_SAVEBITS|CS_OWNDC; wndClass.hbrBackground=(HBRUSH)::GetStockObject(GRAY_BRUSH); } void ImageView::preCreate(MDICREATESTRUCT &createStruct) { createStruct.style=WS_SYSMENU|WS_CAPTION|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VSCROLL|WS_HSCROLL; }