示例#1
0
/************************************************************

 	SaveWallpaper

	  	Saves the current picture into the specified file.
		Installs it as the system wallpaper (uses name given).
		Sets the INI tiled flag to the passed value

		returns FALSE if it could not save wallpaper.
************************************************************/
BOOL SaveWallpaper( LPSTR lpName, BOOL fTiled )
{
WORD idDataType;
STRING szSaveAs;
LPFRAME lpFrame;
int nBits, nPlanes, nDepth, nOutWidth, nOutHeight;

if ( !lpImage )
	return(FALSE);
if ( !(lpFrame = ImgGetBaseEditFrame(lpImage)) )
	return(FALSE);

AstralCursor( IDC_WAIT );	/* Put up the wait cursor */

nBits = GetDeviceCaps( Window.hDC, BITSPIXEL );
nPlanes = GetDeviceCaps( Window.hDC, PLANES );
nDepth = nBits * nPlanes;
nOutWidth = GetDeviceCaps( Window.hDC,HORZRES);
nOutHeight = GetDeviceCaps( Window.hDC,VERTRES);

// decide on proper depth
if ( FrameType(lpFrame) == FDT_LINEART )
	idDataType = IDC_SAVELA;
else
if (nDepth <= 4)
	{
  	if( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVESP;
	else
		idDataType = IDC_SAVE4BITCOLOR;
	}
else
if( nDepth <= 8 || !Control.Save24BitWallpaper)
	{
	if ( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVECT;
	else
		idDataType = IDC_SAVE8BITCOLOR;
	}
else
	{
	if ( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVECT;
	else
		idDataType = IDC_SAVE24BITCOLOR;
	}

// Save file into the Windows directory
GetWindowsDirectory(szSaveAs, sizeof(FNAME));
FixPath( szSaveAs );
lstrcat( szSaveAs, filename(lpName) );
stripext( szSaveAs );
lstrcat( szSaveAs, ".BMP" );

if ( !AstralImageSave( IDN_BMP, idDataType, szSaveAs ) )
	goto ErrorExit;

// Make szSaveAs the current wallpaper and apply
WriteProfileString( "Desktop", "TileWallPaper", (fTiled?"1":"0") );
SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename(szSaveAs),
	SPIF_UPDATEINIFILE );
AstralCursor( NULL ); /* Revert back to the old cursor */
return (TRUE);

ErrorExit:

AstralCursor( NULL ); /* Revert back to the old cursor */
return(FALSE);
}
示例#2
0
BOOL HandleSaveCommand(HWND hWindow, WPARAM wParam, BOOL fCommand)
/***********************************************************************/
{
FNAME szFileName;
//LPSTR lpString;
int idDataType, idOldDataType, idFileType, idOldFileType;
BOOL fChanged, fStatus;
DWORD dwReturn;

if (ImgInMaskEditMode(lpImage))
	{
	ImgSetupMaskEditMode(lpImage);
	UpdateStatusBar(NO, NO, NO, NO);
	}
fStatus = YES;
switch (wParam)
	{
	case IDM_SAVE:
	if ( !lpImage )
		break;
	PPOLEClientNotify( (LPIMAGEOBJECT)lpImage->pObj, OLE_CHANGED );
#ifdef USEOLE
	OleSavedServerDoc( lpImage->lhDoc );
#endif // #ifdef USEOLE
	if ( lpImage->fOwnedByClient )
		{ // If it IS embedded client data, inform the client
//		ImgEditApplyAll( lpImage, YES/*fApplyData*/, YES/*fApplyAlpha*/ );
		break;
		}
	/* Save the image under the current name */
	if ( !lpImage->fUntitled) /* If the picture has a name, save into it */
		{
		if ( !(fStatus = AstralImageSave( lpImage->FileType,
			lpImage->DataType, lpImage->CurFile )) )
			break;
		SetImgChanged(lpImage, NO);
//		ImgEditApplyAll( lpImage, YES/*fApplyData*/, YES/*fApplyAlpha*/ );
		break;
		}
	/* else fall through to SaveAs... */

	case IDM_SAVEAS:
	if ( !lpImage )
		break;
	/* Bring up the modal 'SaveAs' box */
	// save current image format information
	lstrcpy(szFileName, lpImage->CurFile);
	fChanged = lpImage->fChanged;
	idOldDataType = lpImage->DataType;
	idOldFileType = IDN_ART;    // save all as ART files

	// ask user for a name
	if ( !(dwReturn = DoOpenDlg( hWindow, IDD_SAVEAS,
	     lpImage->FileType, szFileName, YES )) )
		{
		fStatus = NO;
		break;
		}

	// save the image in the user specified file type and data type
	idFileType = LOWORD( dwReturn );
	idDataType = HIWORD( dwReturn );

	if ( !(fStatus = AstralImageSave( idFileType, idDataType, szFileName )))
		break;

//	// If it IS NOT embedded client data, inform the client
	PPOLEClientNotify( (LPIMAGEOBJECT)lpImage->pObj, OLE_CHANGED );
	
#ifdef USEOLE
	OleSavedServerDoc( lpImage->lhDoc );
#endif // #ifdef USEOLE
	
	// whenever you save changes become permanent - NOT ANY MORE - tmr
	SetImgChanged(lpImage, NO);
//	ImgEditApplyAll( lpImage, YES/*fApplyData*/, YES/*fApplyAlpha*/ );

	// Add the file name to our recall list
	AddRecallImageName( szFileName );

	if (!fCommand)
		break;

	// If this is a chunked image, don't revert or change name
	if (lpImage->DocumentType == IMG_DOCPIECE)
		break;
	if (ImgInMaskEditMode(lpImage))
		break;

	// if data type or file type did not change, just take new name
	if ( idDataType == idOldDataType && idFileType == idOldFileType )
		{ // it has the same FileType, same DataType
		lpImage->fUntitled = NO;
			lstrcpy( lpImage->CurFile, szFileName );
			/* Force the non-client area (title bar) of image to paint */
				SetTitleBar(lpImage->hWnd);
#ifdef USEOLE		
		// If it IS NOT embedded client data, inform the client
		OleRenameServerDoc( lpImage->lhDoc, lpImage->CurFile);
#endif // #ifdef USEOLE		
		break;
		}

	// see if the user wants to convert to using the new format
	if ( !AstralAffirm(IDS_CONFIRM_CONVERT) )
		{ // the user doesn't want to convert to the new format
		lpImage->fChanged = fChanged; // restore the changed flag
		break;
		}

	// the user wants to convert to the new format
	lpImage->FileType = idFileType;
	lpImage->DataType = idDataType;
	lpImage->fUntitled = NO;
	lstrcpy( lpImage->CurFile, szFileName );
	/* Force the non-client area (title bar) of image to paint */
		SetTitleBar(lpImage->hWnd);
#ifdef USEOLE		
		// If it IS NOT embedded client data, inform the client
		OleRenameServerDoc( lpImage->lhDoc, lpImage->CurFile);
#endif // #ifdef USEOLE		
	DoCommand(hWindow, IDM_REVERT, 0L);
	break;

	case IDM_SAVESPECIAL:
	if ( !lpImage )
		break;
	// save current image format information
	lstrcpy(szFileName, lpImage->CurFile);
	fChanged = lpImage->fChanged;
	idOldDataType = lpImage->DataType;
	idOldFileType = IDN_ART;    // save all as ART files

	if (lpImage->fUntitled)
	{
    	// get the new name for the file
    	GetNextIniFilename ((char FAR *)&szFileName);
    	SaveToIniEntry (szFileName, NULL);
    }
	else
	{
		lstrcpy (szFileName, lpImage->CurFile);
	}
    // save the image as the same type
    idFileType = idOldFileType;
    idDataType = idOldDataType;
	if ( !(fStatus = AstralImageSave( idFileType, idDataType, szFileName )))
		break;

	// whenever you save changes become permanent - NOT ANY MORE - tmr
	SetImgChanged(lpImage, NO);
//	ImgEditApplyAll( lpImage, YES/*fApplyData*/, YES/*fApplyAlpha*/ );

	// Add the file name to our recall list
	AddRecallImageName( szFileName );

	if (!fCommand)
		break;

	// If this is a chunked image, don't revert or change name
	if (lpImage->DocumentType == IMG_DOCPIECE)
		break;
	if (ImgInMaskEditMode(lpImage))
		break;

	// if data type or file type did not change, just take new name
	if ( idDataType == idOldDataType && idFileType == idOldFileType )
		{ // it has the same FileType, same DataType
		lpImage->fUntitled = NO;
			lstrcpy( lpImage->CurFile, szFileName );
			/* Force the non-client area (title bar) of image to paint */
				SetTitleBar(lpImage->hWnd);
#ifdef USEOLE
	OleRenameServerDoc( lpImage->lhDoc, lpImage->CurFile );
#endif // #ifdef USEOLE
		break;
		}

	// see if the user wants to convert to using the new format
	if ( !AstralAffirm(IDS_CONFIRM_CONVERT) )
		{ // the user doesn't want to convert to the new format
		lpImage->fChanged = fChanged; // restore the changed flag
		break;
		}

	// the user wants to convert to the new format
	lpImage->FileType = idFileType;
	lpImage->DataType = idDataType;
	lpImage->fUntitled = NO;
	lstrcpy( lpImage->CurFile, szFileName );
	/* Force the non-client area (title bar) of image to paint */
		SetTitleBar(lpImage->hWnd);
	// If it IS NOT embedded client data, inform the client
#ifdef USEOLE
	OleRenameServerDoc( lpImage->lhDoc, lpImage->CurFile );
#endif // #ifdef USEOLE
	DoCommand(hWindow, IDM_REVERT, 0L);
	break;

	default:
	break;
	}

return( fStatus );
}