예제 #1
0
// OutputToStream()
//  Outputs an ImageData instance as ASCII text to the stream provided.
void ImageData::OutputToStream( ostream &out ) {
  out << " Filename:             \"" << GetFilename() << "\"" << endl;
  out << "  File Format:         " << GetFileFormat() << "; \"" << ImageFileFormatStrings[ GetFileFormat() ] << "\"" << endl;
  out << "  File Size:           " << GetFileSize() << " bytes " << endl;
  out << endl;
  out << " File Data:" << endl;
  out << "  Bits Per Pixel:      " << GetBitsPerPixel() << endl;
  out << "  Compression:         " << GetCompression() << "; \"" << ImageCompressionModeStrings[ GetCompression() ] << "\"" << endl;
  out << "  DPI X/Y:             " << GetDPIX() << "/" <<  GetDPIY() << endl;
  out << "  Pixel Aspect Ration: " << GetPixelAspectNum() << "/" <<  GetPixelAspectDenom() << endl;
  out << "  Gamma Correction:    " << GetGammaNum() << "/" <<  GetGammaDenom() << endl;
  out << "  Thumbnail:           ";
  if( GetThumbnail() == NULL )
    out << "No" << endl;
  else
    out << "Yes" << endl;

  out << endl;
  out << " Creator Data:" << endl;
  out << "  Author:              \"" << GetAuthor() << "\"" << endl;
  out << "  Creator Program:     \"" << GetCreator() << "\"" << endl;
  out << "  Creator Version:     "   << GetCreatorVersion() << "." << GetCreatorRevision() << GetCreatorSubRev() << endl;
  out << "  Comment:             \"" << GetComment() << "\"" << endl;
  out << "  Job Name:            \"" << GetJobName() << "\"" << endl;
  out << "  Job Time:            "   << GetJobTime()[0] << ":" << GetJobTime()[1] << ":" << GetJobTime()[2] << endl;
  out << "  Date Stamp:          "   << GetDateStamp()[0] << "/" << GetDateStamp()[1] << "/" << GetDateStamp()[2] << "  "
                                     << GetDateStamp()[3] << ":" << GetDateStamp()[4] << ":" << GetDateStamp()[5] << endl;
  out << endl;

  out << " Image Data:" << endl;
  out << "  Width:               " << GetImage()->GetWidth() << endl;
  out << "  Height:              " << GetImage()->GetHeight() << endl;
  out << "  Type:                " << GetImage()->GetType() << "; \"" << ImageTypeStrings[ GetImage()->GetType() ] << "\"" << endl;
  out << "  Num Registers:       ";
  if( GetImage()->GetType() == IMAGE_INDEXED )
    out << GetImage()->GetNumRegisters() << endl;
  else
    out << "N/A" << endl;

}
예제 #2
0
BOOL CPubThread::Disk(LPPUBINFO ppi)
{
	if ( ppi == NULL ) return FALSE;

	// Is it an avi file
	if ( *ppi->avicachefile != 0 )
	{
		// Build target filename
		char fname[ CWF_STRSIZE ];
		CWinFile::BuildPath( fname, ppi->path, ppi->pub_fname );

		// Copy the file
		if ( !MoveFile( ppi->avicachefile, fname ) )
			CopyFile( ppi->avicachefile, fname, FALSE );

	} // end if

	else
	{
		CWinImg img;

		// Get the image
		if ( !IMGLIST().GetImage( ppi->img, &img ) )
		{	_Log( MB_ICONERROR, ppi->img, "Invalid image." );
			return FALSE;
		} // end if

		// Inform user
		char msg[ CWF_STRSIZE ];
		wsprintf( msg, "Saving %s to %s", ppi->pub_fname, ppi->path );
		FRAME()->SetStatus( msg );

		char fname[ CWF_STRSIZE ];
		CWinFile::BuildPath( fname, ppi->path, ppi->pub_fname );
		
		// Save the file
		if ( !img.Save( fname ) )
		{	_Log( MB_ICONERROR, ppi->img, img.GetLastError() );
		} // end if

	} // end else

	// Punt if no thumbnail
	if ( ( ppi->f1 & PUBF1_THUMBNAIL ) == 0 ) return TRUE;

	// Is it an avi file
	if ( *ppi->thmavicachefile != 0 )
	{
		// Build target filename
		char fname[ CWF_STRSIZE ];
		CWinFile::BuildPath( fname, ppi->path, ppi->pub_tfname );

		// Copy the file
		if ( !MoveFile( ppi->thmavicachefile, fname ) )
			CopyFile( ppi->thmavicachefile, fname, FALSE );

	} // end if

	else
	{
		CWinImg img;

		// Get thumbnail
		GetThumbnail( ppi, &img, img.GetWidth(), img.GetHeight() );

		// Build thumbnail path
		char fname[ CWF_STRSIZE ];
		CWinFile::BuildPath( fname, ppi->path, ppi->pub_tfname );
		
		// Save thumbnail
		if ( !img.Save( fname ) )
		{	_Log( MB_ICONERROR, ppi->img, img.GetLastError() );
		} // end if

	} // end else

	return TRUE;
}
예제 #3
0
BOOL CPubThread::Ftp( LPPUBINFO ppi )
{
	if ( ppi == NULL ) return FALSE;

	// Ensure ftp server
	HGROUP hGroup = FTPSERVERS().FindGroup( ppi->str );
	if ( hGroup == NULL )
	{	_Log( MB_ICONERROR, ppi->str, "FTP Server information not found" );	
		return FALSE;
	} // end if

	BOOL bPublished = FALSE;
	LPBYTE buf = NULL;
	DWORD size = 0;
	TMem< BYTE > temp;
	CWinImg img;

	// Is it an avi file
	if ( *ppi->avicachefile != 0 )
	{
		CWinFile wf;
		if ( wf.OpenExisting( ppi->avicachefile ) )
		{	size = wf.Size();
			if ( size && temp.allocate( size ) && wf.Read( temp.ptr(), temp.size() ) )
				buf = (LPBYTE)temp.ptr();
		} // end if
		
	} // end if
	else
	{
		// Get the image
		if ( !IMGLIST().GetImage( ppi->img, &img ) )
		{	_Log( MB_ICONERROR, ppi->img, "Image not found" );	
			return FALSE;
		} // end if

		// Set jpeg quality
		FRAME()->SetQuality( &img );

		// Encode the file
		if ( !img.Encode( &buf, &size, ppi->pub_fname ) ) 
		{	_Log( MB_ICONERROR, ppi->img, img.GetLastError() );	
			return FALSE;
		} // end if

	} // end else

	// Want Win32 interface?
	if ( FTPSERVERS().GetDword( hGroup, "Rename", FALSE ) )
	{
		// Create FTP object if needed
		if ( ppi->pftp == NULL ) ppi->pftp = new CFtp();
		if ( ppi->pftp == NULL )
		{	_Log( MB_ICONERROR, "Ftp()", "Out of memory" );	
			return FALSE;
		} // end if

		// Is the FTP already working?
		if ( !ppi->pftp->IsConnecting() && !ppi->pftp->IsConnected() )
		{

			// Copy the memory
			if ( ppi->mem == NULL || !ppi->mem->put( buf, size ) )
			{	_Log( MB_ICONERROR, "Ftp()", "Memory error" );	
				return FALSE;
			} // end if

			// Upload the data
			bPublished = FtpImage( ppi->str, ppi->pftp, *ppi->mem, ppi->mem->size(), ppi->pub_fname );
		} // end if

	} // end if

	else 
	{
		// Create FTP object if needed
		if ( ppi->pw32ftp == NULL ) ppi->pw32ftp = new CNetFile();
		if ( ppi->pw32ftp == NULL )
		{	_Log( MB_ICONERROR, "Ftp()", "Out of memory" );	
			return FALSE;
		} // end if

		// Use Windows interface
		bPublished = FtpImage( ppi->str, ppi->pw32ftp, buf, size, ppi->pub_fname );

	} // end else

	// Punt if no thumbnail
	if ( ( ppi->f1 & PUBF1_THUMBNAIL ) == 0 ) return bPublished;

	// Load image if we haven't already
	if ( !img.IsValid() )
	{
		// Get the image
		if ( !IMGLIST().GetImage( ppi->img, &img ) )
		{	_Log( MB_ICONERROR, ppi->img, "Image not found" );	
			return FALSE;
		} // end if

		// Set jpeg quality
		FRAME()->SetQuality( &img );

		// Encode the file
		if ( !img.Encode( &buf, &size, ppi->pub_fname ) ) 
		{	_Log( MB_ICONERROR, ppi->img, img.GetLastError() );	
			return FALSE;
		} // end if

	} // end if

	// Get the thumbnail image
	if ( !GetThumbnail( ppi, &img, img.GetWidth(), img.GetHeight() ) )
		return FALSE;

	// Set jpeg quality
	FRAME()->SetQuality( &img );

	// Encode the thumbnail file
	if ( !img.Encode( &buf, &size, ppi->pub_tfname ) ) return FALSE;

	// Want Win32 interface?
	if ( FTPSERVERS().GetDword( hGroup, "Rename", FALSE ) )
	{
		// Create FTP object if needed
		if ( ppi->pftpthm == NULL ) ppi->pftpthm = new CFtp();
		if ( ppi->pftpthm == NULL )
		{	_Log( MB_ICONERROR, "Ftp()", "Out of memory" );	
			return FALSE;
		} // end if

		// Is the FTP already working?
		if ( !ppi->pftpthm->IsConnecting() && !ppi->pftpthm->IsConnected() )
		{
			// Copy the memory
			if ( ppi->tnmem == NULL || !ppi->tnmem->put( buf, size ) )
			{	_Log( MB_ICONERROR, "Ftp()", "Memory error" );
				return FALSE;
			} // end if

			// Upload the data
			FtpImage( ppi->str, ppi->pftpthm, *ppi->tnmem, ppi->tnmem->size(), ppi->pub_tfname );

		} // end if

	} // end if

	else 
	{
		// Create FTP object if needed
		if ( ppi->pw32ftpthm == NULL ) ppi->pw32ftp = new CNetFile();
		if ( ppi->pw32ftpthm == NULL )
		{	_Log( MB_ICONERROR, "Ftp()", "Memory error" );
			return FALSE;
		} // end if

		// Use Windows interface
		FtpImage( ppi->str, ppi->pw32ftpthm, buf, size, ppi->pub_tfname );

	} // end else

	return bPublished;
}