Example #1
0
void CChromaDlg::ShowChromaPreview()
{
    HWND hDlg 		= GetSafeHwnd();
	RECT rMask;
	HWND hActiveWnd;
	LPIMAGE lpImage = GetImage();


   	hActiveWnd = m_pView->GetSafeHwnd();
	if (!hActiveWnd)
		return;

	lpChromaMask->iMode = ImgGetViewMode(lpImage);
   	ImgSetViewMode(lpImage, VM_SLIME);
	if (ImgGetMask(lpImage))
		ImgGetMaskRect(lpImage, &rMask);
	else
		ImgGetSelObjectRect(lpImage, &rMask, NO);

	File2DispRect(hActiveWnd, &rMask, &rMask);

	if (Tool.id == IDC_CHROMA)
		AstralUnionRect(&rMask, &rMask, &rPreview);

	ImgGetMaskRect(lpImage, &rPreview);
	File2DispRect(hActiveWnd, &rPreview, &rPreview);
	SetMaskHook(hActiveWnd, (LPMASKHOOK)lpChromaMask);
	AstralCursor( IDC_WAIT );
	::InvalidateRect(hActiveWnd, &rMask, FALSE);
	AstralUpdateWindow(hActiveWnd);
	ControlEnable(hDlg, IDC_RESET, YES );
	AstralCursor(NULL);
}
Example #2
0
static void DrawBox( HWND hWnd, HDC hDC )  // Assumes zoom box is current view!
/************************************************************************/
{
RECT rFile, rDraw;
HWND hOwner;
LPDISPLAY lpOwnerDisp, lpMyDisp;

hOwner = GetZoomOwner(hWnd);
if (!hOwner)
	return;
lpOwnerDisp = (LPDISPLAY)GetDisplayPtr(hOwner);
lpMyDisp = (LPDISPLAY)GetDisplayPtr(hWnd);
if (!lpOwnerDisp || !lpMyDisp)
	return;

//rDisp = lpMyDisp->DispRect;
rFile = lpMyDisp->FileRect;

// get owners file rect and convert to our file rect

rDraw.left = lpOwnerDisp->FileRect.left-rFile.left;
rDraw.top= lpOwnerDisp->FileRect.top-rFile.top;
rDraw.right= lpOwnerDisp->FileRect.right-rFile.left;
rDraw.bottom= lpOwnerDisp->FileRect.bottom-rFile.top;


// convert into our display rect
File2DispRect(hWnd, &rDraw, &rDraw);

// limit to display rect
IntersectRect(&rDraw, &rDraw, &(lpMyDisp->DispRect));

//rDraw.left++;
//rDraw.top++;

//old way:fRate = FGET(rDisp.right-rDisp.left, rFile.right-rFile.left);
//rDraw.left = FMUL(rDraw.left,fRate);
//rDraw.right = FMUL(rDraw.right,fRate);
//fRate = FGET(rDisp.bottom-rDisp.top, rFile.bottom-rFile.top);
//rDraw.top = FMUL(rDraw.top,fRate);
//rDraw.bottom = FMUL(rDraw.bottom,fRate);

// Invert the box
InvertBox(hDC, &rDraw);

// remeber box
SetWindowWord( hWnd, GWW_ZOOMBOXLEFT, (WORD)rDraw.left);
SetWindowWord( hWnd, GWW_ZOOMBOXTOP, (WORD)rDraw.top);
SetWindowWord( hWnd, GWW_ZOOMBOXRIGHT, (WORD)rDraw.right);
SetWindowWord( hWnd, GWW_ZOOMBOXBOTTOM, (WORD)rDraw.bottom);
}
Example #3
0
static void AnimateUndo( LPRECT lpUndoRect )
/***********************************************************************/
{
RECT rect;
STRING szString;
ITEMID id1, id2;
int iHeight, iWidth, x1, x2, y;
#define DXANIMATION 71
#define DYANIMATION 76

SoundStartID( IDC_AMBULANCE1, YES/*bLoop*/, NULL/*hInstance*/ );
GetClientRect( lpImage->hWnd, &rect );
iHeight = RectHeight( &rect );
iWidth = RectWidth( &rect );
File2DispRect( lpUndoRect, &rect );
x1 = (rect.left + rect.right) / 2;
if ( x1 < iWidth - x1 )
	{ // closer to the left; come in from the left
	x1 = -DXANIMATION;
	x2 = rect.right;
	id1 = IDC_AMBULANCE2;
	id2 = IDC_AMBULANCE1;
	}
else
	{ // closer to the right; come in from the right
	x1 = iWidth - 1;
	x2 = rect.left - DXANIMATION;
	id1 = IDC_AMBULANCE1;
	id2 = IDC_AMBULANCE2;
	}
y = (rect.top + rect.bottom - DYANIMATION) / 2;
y = bound( y, 0, iHeight - DYANIMATION );

wsprintf( szString, "SETSPEED 35\rJUMP %d,%d\rMOVE %d,%d\r", x1, y, x2, y );
AnimateDibID( lpImage->hWnd, NULL/*&rect*/, hInstAstral, id1, NULL, szString );

UpdateImage( lpUndoRect, YES );
AstralUpdateWindow( lpImage->hWnd );

wsprintf( szString, "SETSPEED 35\rJUMP %d,%d\rMOVE %d,%d\r", x2, y, x1, y );
AnimateDibID( lpImage->hWnd, NULL/*&rect*/, hInstAstral, id2, NULL, szString );
SoundStop();
}
Example #4
0
void ImgEditMaskUndo( LPIMAGE lpImage )
/***********************************************************************/
{
LPOBJECT lpBase;
LPMASK lpMask;
RECT rUndo;

lpBase = ImgGetBase(lpImage);
if (!lpBase->AlphaDirty)
	return;
if (lpBase->fBothDirty)
	return;

AstralSetRectEmpty(&rUndo);
if (ImgGetMask(lpImage) &&
	lpBase->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) )
	{
	RemoveMaskMarquee(lpImage);
	ImgGetMaskUpdateRect(lpImage, YES, NO, &rUndo);
	}

ObjEditUndo(lpImage, lpBase, NO, YES);

if (lpMask = ImgGetMask(lpImage))
	{
	if (lpBase->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) )
		{
		RemoveMaskMarquee(lpImage);
		ImgGetMaskUpdateRect(lpImage, YES, NO, &rUndo);
		}
	else
		rUndo = lpMask->Pixmap.UndoRect;
	}
if (rUndo.right >= rUndo.left)
	{
	OffsetRect(&rUndo, lpBase->rObject.left, lpBase->rObject.top);
	File2DispRect(&rUndo, &rUndo);
	AstralToWindowsRect(&rUndo);
	InvalidateRect(lpImage->hWnd, NULL, NO);
	}
}
Example #5
0
void CImage::EditMaskUndo()
{
LPOBJECT lpBase;
LPMASK lpMask;
RECT rUndo;

lpBase = GetBase();
if (!lpBase->AlphaDirty)
	return;
if (lpBase->fBothDirty)
	return;

AstralSetRectEmpty(&rUndo);
if (GetMask() &&
	lpBase->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) )
	{
	RemoveMaskMarquee(this);
	GetMaskUpdateRect(YES, NO, &rUndo);
	}

ObjEditUndo(lpBase, NO, YES);

if (lpMask = GetMask())
	{
	if (lpBase->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) )
		{
		RemoveMaskMarquee(this);
		GetMaskUpdateRect(YES, NO, &rUndo);
		}
	else
		rUndo = lpMask->Pixmap.UndoRect;
	}
if (rUndo.right >= rUndo.left)
	{
	OffsetRect(&rUndo, lpBase->rObject.left, lpBase->rObject.top);
	File2DispRect(GetActiveDoc(), &rUndo, &rUndo);
	AstralToWindowsRect(&rUndo);
	InvalidateRect(GetActiveDoc(), NULL, NO);
	}
}
Example #6
0
void ImgEditUndo( LPIMAGE lpImage, BOOL fEditUndo, BOOL fMaskUndo )
/***********************************************************************/
{
RECT rUndo, rUndoMask, rTemp;
LPOBJECT lpBase, lpObject, lpNext;
BOOL fNewSize, fSetupMiniViews, fRemoveMarquee, fUndoDelete;
BOOL fUndoAlpha, fUndoData;
int nDeleted;
LPMASK lpMask;

if (!lpImage)
	return;

// Initialize things for updating the display
fNewSize = fSetupMiniViews = fUndoDelete = NO;
AstralSetRectEmpty(&rUndo);
AstralSetRectEmpty(&rUndoMask);

// loop through objects doing undo
lpBase = ImgGetBase(lpImage);
lpObject = NULL;
while (lpObject = ImgGetNextObjectEx(lpImage, lpObject, NO, NO, fEditUndo))
	{
	// See if this is an object we are undoing
	if (fEditUndo)
		{
		// check for special undo processing of a deleted object
		if (lpObject->fDeleted) 
			{
			if (Control.UndoObjects && !ImgIsSelectedObject(lpImage, lpBase))
				continue;
			}
		else
		if (Control.UndoObjects && !ImgIsSelectedObject(lpImage, lpObject))
			continue;
		}
	// Only handle mask undo for the base object
	if (fMaskUndo)
		{
		if (lpObject != lpBase || lpObject->fBothDirty ||
			!lpObject->AlphaDirty)
		continue;
		}

	fUndoData = fUndoAlpha = NO;

	// Do preprocess for doing a data undo
	if (fEditUndo)
		{
		if (lpObject->DataDirty)
			fUndoData = YES;
		// See if we need to undo the alpha for this object
		if ((lpObject != lpBase) && lpObject->lpAlpha && lpObject->AlphaDirty)
			fUndoAlpha = YES;
		if (!fUndoData && !fUndoAlpha)
			continue;
	
		// check to see and undoing/redoing deleted objects will change
		// the select state, if so undraw the object marquee
		if (lpObject == lpBase &&
			lpObject->DataUndoType & UT_DELETEOBJECTS)
			{
			fUndoDelete = YES;
			fRemoveMarquee = NO;
			nDeleted = 0;
			lpNext = lpObject;
			while (lpNext = ImgGetNextObjectEx(lpImage, lpNext, YES, NO, YES))
				{
				if (lpNext->fUndoDeleted)
					++nDeleted;
				else
				if (lpNext->fDeleted && lpNext->fSelected)
					{
					fRemoveMarquee = YES;
					break;
					}
				}
			if (ImgGetSelObject(lpImage, NULL) == lpBase && !fRemoveMarquee)
				{
				if (ImgCountObjects(lpImage) - nDeleted <= 1)
					fRemoveMarquee = YES;
				}
			if (fRemoveMarquee)
				RemoveObjectMarqueeEx(lpImage, NO);
			}
		}
	else // fMaskUndo
	if (!lpObject->AlphaDirty)
		continue;
	else
		fUndoAlpha = YES;

	// do a preprocess for undoing the mask caused either by
	// a mask undo or by an edit function that also edits the mask
	if (((lpObject == lpBase) && fEditUndo && lpObject->fBothDirty) ||
		fMaskUndo)
		{
		if ( lpObject->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) )
			{
			// if the undo is going to delete the mask,
			// we need to undraw the mask
			if (ImgGetMask(lpImage))
				{
				RemoveMaskMarquee(lpImage);
				if (ImgGetMaskUpdateRect(lpImage, YES, NO, &rTemp))
					AstralUnionRect(&rUndoMask, &rUndoMask, &rTemp);
				}
			// if the undo is going to create the mask,
			// we need to undraw the object marquees if
			// not in mask and object marquee mode
			else
				{
				if (!Control.UseMaskAndObjects)
 					RemoveObjectMarqueeEx(lpImage, NO);
				}
			}
		}

	// Actually do the undo
	ObjEditUndo(lpImage, lpObject, fUndoData, fUndoAlpha);

	// do a postprocess for undoing the mask
	if ((lpMask = ImgGetMask(lpImage)) &&
		(((lpObject == lpBase) && fEditUndo && lpObject->fBothDirty) ||
		fMaskUndo))
		{
		// if the undo is going to add the mask, we need to redraw the mask
		if (lpObject->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) )
			{
			if (ImgGetMaskUpdateRect(lpImage, YES, NO, &rTemp))
				AstralUnionRect(&rUndoMask, &rUndoMask, &rTemp);
			}
		else
			// just redraw the undo area for the mask
			AstralUnionRect(&rUndoMask, &rUndoMask, &lpMask->Pixmap.UndoRect);
		}

	// Setup rectangle for undoing deletion of objects
	// Handled specially so that moved objects will still undo
	// and redo properly
	if (fEditUndo)
		{
		if (lpObject == lpBase &&
			lpObject->DataUndoType & UT_DELETEOBJECTS)
			{
			lpNext = lpObject;
			while (lpNext = ImgGetNextObjectEx(lpImage, lpNext, YES, NO, YES))
				{
				if (lpNext->fDeleted || lpNext->fUndoDeleted)
					AstralUnionRect(&rUndo, &rUndo, &lpNext->rObject);
				}
			fSetupMiniViews = YES;
			}

		if (lpObject->Pixmap.fNewFrame)
			{
			/* if new frame, cause window to be redisplayed */
			if (lpObject == lpBase)
				fNewSize = YES;
			else
				{
				if (!fNewSize)
					{
					AstralUnionRect(&rUndo, &rUndo, &lpObject->rObject);
					AstralUnionRect(&rUndo, &rUndo, &lpObject->rUndoObject);
					}
				}
			}
		else
			{
			AstralSetRectEmpty(&rTemp);
			if (fUndoData)
				AstralUnionRect(&rTemp, &rTemp, &lpObject->Pixmap.UndoRect);
			if (fUndoAlpha)
				AstralUnionRect(&rTemp, &rTemp,
						&lpObject->lpAlpha->Pixmap.UndoRect);
			if (rTemp.right >= rTemp.left)
				{
				if (!fNewSize)
					{
					OffsetRect(&rTemp, lpObject->rObject.left,
							lpObject->rObject.top);
					AstralUnionRect(&rUndo, &rUndo, &rTemp);
					}
				}
			}
		}
	}
// now redisplay whatever changes are necessary for the undo
if (fNewSize)
	{
	SetupImagePalette(lpImage, NO, YES);
	if (lpBase->Pixmap.UndoFrame)
		{
		if ((FrameXSize(lpBase->Pixmap.UndoFrame) ==
			FrameXSize(lpBase->Pixmap.EditFrame)) &&
			(FrameYSize(lpBase->Pixmap.UndoFrame) ==
			FrameYSize(lpBase->Pixmap.EditFrame)))
			fNewSize = NO;
		}
	if (fNewSize)
		UpdateImageSize();
	else
		UpdateImageEx(lpImage, NULL, YES, YES, YES);
	if ( Tool.hRibbon )
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
	}
else
	{
	if (rUndoMask.right >= rUndoMask.left)
		{
		File2DispRect(&rUndoMask, &rUndoMask);
		AstralToWindowsRect(&rUndoMask);
		InvalidateRect(lpImage->hWnd, NULL, NO);
		}
	if (rUndo.right >= rUndo.left)
		AnimateUndo( &rUndo );
	}
if (fUndoDelete)
	if ( Tool.hRibbon )
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
	
if (fSetupMiniViews)
	SetupMiniViews(NULL, NO);
}