Click here to Skip to main content
15,896,557 members
Articles / Desktop Programming / MFC

Scan2PDF

Rate me:
Please Sign up or sign in to vote.
4.90/5 (75 votes)
22 Apr 20053 min read 434.7K   20.9K   230  
A utility for bulk scanning, converting the scanned pages to PDF and burning them on CD/DVD for archiving.
/******************************************************************************
|* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|* PARTICULAR PURPOSE.
|* 
|* Copyright 1995-2004 Ahead Software AG. All Rights Reserved.
|*-----------------------------------------------------------------------------
|* NeroSDK / NeroCmd
|*
|* PROGRAM: WriteVideoCD.cpp
|*
|* PURPOSE: Burn Video CDs
******************************************************************************/


#include "stdafx.h"
#include "BurnContext.h"


// This function performs burning Video or Super Video CDs.

CExitCode CBurnContext::WriteVideoCD (const PARAMETERS & params)
{
	int iSize;
	NERO_WRITE_VIDEO_CD * pWriteCD;
	EXITCODE code;
	NERO_ISO_ITEM * pItem = NULL;

	// Calculate the size required for NERO_WRITE_CD plus the given number of tracks

	iSize = sizeof (NERO_WRITE_VIDEO_CD) + (params.GetNumberOfTracks() - 1) * sizeof (NERO_VIDEO_ITEM);

	// Allocate the required memory and assign it to the NERO_WRITE_CD pointer

	pWriteCD = (NERO_WRITE_VIDEO_CD *) new char[iSize];
	if (!pWriteCD)
	{
		return EXITCODE_OUT_OF_MEMORY;
	}

	// Fill the allocated memory with null bytes

	memset (pWriteCD, 0, iSize);

	// Fill in the basic information

	pWriteCD->nwvcdSVCD = (BURNTYPE_SVIDEOCD == params.GetBurnType())? true: false;
	pWriteCD->nwvcdNumItems = params.GetNumberOfTracks();

	pWriteCD->nwvcdLongTempPath = params.GetTempPath ();

	pWriteCD->nwvcdEncodingResolution = params.GetVideoResolution ();

	try
	{
		// Get the ISO track from the information in the parameters.

		code = GetIsoTrack (params, &pWriteCD->nwvcdIsoTrack, &pItem);
		if (code != EXITCODE_OK)
		{
			throw code;
		}

		for (int i = 0; i < params.GetNumberOfTracks(); i ++)
		{
			// Helper variables to promote readability

			LPCSTR psFilename = params.GetTrackFileName(i);
			NERO_VIDEO_ITEM * item = &pWriteCD->nwvcdItems[i];

			item->nviLongSourceFileName = psFilename;

			// MPEG and JPEG are allowed types
			// stricmp performs a lowercase comparison and returns 0 if the strings are identical.
			// We fill in type information and file name.

			LPCSTR psExt = strrchr (psFilename, '.');

			if (psExt && (!stricmp (psExt, ".mpg") || !stricmp (psExt, ".mpeg")))
			{
				item->nviItemType = NERO_MPEG_ITEM;

				// no pause after mpeg items

				item->nviPauseAfterItem=0;
			}
			else if (psExt && (!stricmp (psExt, ".avi")))
			{
				item->nviItemType = NERO_NONENCODED_VIDEO_ITEM;
				
				// no pause after avi items

				item->nviPauseAfterItem=0;
			}
			else if (psExt && (!stricmp (psExt, ".jpg") || !stricmp (psExt, ".jpeg")))
			{
				item->nviItemType = NERO_JPEG_ITEM;
				
				// infinite pause after jpeg items
				
				item->nviPauseAfterItem=-1;
			}
			else
			{
				m_ErrorLog.printf ("Unknown file type '%s'\n", params.GetTrackFileName(i));
				
				throw EXITCODE_UNKNOWN_FILE_TYPE;
			}
		}
		
		NEROAPI_BURN_ERROR err;
		CBurnContextProgress m_NeroProgress;
		
		// Perform the actual burn process

		err = NeroBurn (m_NeroDeviceHandle,
						NERO_VIDEO_CD,
						pWriteCD,
						GetBurnFlags (params),
						params.GetSpeedToNeroBurn (),
						m_NeroProgress);

		code = TranslateNeroToExitCode (err);
	}
	catch (EXITCODE e)
	{
		code = e;
	}

	// Free allocated memory

	NeroFreeIsoTrack (pWriteCD->nwvcdIsoTrack);
	DeleteIsoItemTree (pItem);
	delete [] (char *)pWriteCD;

	return code;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Solaris Electronics LLC
United Arab Emirates United Arab Emirates
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acquisition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competition, my articles are:


You can see list of my articles, by clicking here


Comments and Discussions