( Index )
Month

Brief Information about the January 2002 CSIG Meeting

MkThumb and MkHtml - Utilities to Create an HTML Driven Picture Menu

3rd Tuesday of the month. 7:30PM - C/C++ Group, SPRS

Welcome to the C++ Users Group. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

Sample Output

The object of this month's program is display a picture menu. Digital cameras are very popular these days. It's very easy to accumulate hundreds of photos but then how do you show them to other people? You may e-mail them, or burn them on a CD-ROM, or put them on a personal homepage. But will the person seeing them have a suitable JPEG viewer? If they have a basic Windows computer they will have an Internet browser. This is a good start but each picture may be too big or two small. Also, clicking on each filename to go through 100 pictures is quite poor.

As shown above this month's utility will create a menu of icons which are thumbnail versions of the real pictures that can then be clicked to see a full-screen image. A typical thumbnail is less than 5 KBytes so the menu is draw very fast even for hundreds of items.

This month's program uses a Command Box Application and a JPEG Library from INTEL. The first program, MkThumb.exe, will take a directory of any size filled with JPEG files and create small thumbnails of the files and locate them in a separate subdirectory called Thumbs. The second program, MkHTML.exe, will go through these folders and create HTML files which together represent a menu system. There is an HTML file for each thumbnail. This is necessary in order to provide the sizing functionality.

It works under Windows 95, 98, 98se, ME, NT, 2000, and XP.

At the meeting on Tuesday night we will be discussing the utility and the source code.


SAMPLE CODE
===========
int main(int argc, char **argv)
	{
    int i, count;
	thumbs  = "Thumbs";
	afn     = "*.JPG";
	BITMAPINFOHEADER* pDIB;

	if (argc < 2) { puts(VERSION); return 0; }

	if (!strcmp(argv[1], "2"))	mode = ONEHALF;
	.........
	count = getfiles(afn);
	qsort((void *)filename, count, sizeof(char *), compare);

	for (i=0; i<count; i++)
		{
		CString sThumb;
		sThumb = thumbs; sThumb += "\\"; sThumb += filename[i];
		printf("%d\t%s", i+1, filename[i]);
		if (DecodeJPGFileToDIB(filename[i], &pDIB))
			{
			printf("...Read");
			if (EncodeJPGFileFromDIB(sThumb.GetBuffer(50), pDIB))
				printf("...Written");
			delete [] pDIB;
			}
		puts("");
		}
	for (i=0; i<count; i++)
		{
		free(filename[i]);
		}
	return 0;
	}

int getfiles(char *afn)
    {
    WIN32_FIND_DATA fd;		int i=0;
    HANDLE hFind;
    CString name;
    
    hFind= ::FindFirstFile( (LPCTSTR) afn, &fd);
    if (hFind != INVALID_HANDLE_VALUE)
        {
        do
            {
            if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
            name = fd.cFileName;
			filename[i++] = strdup(name.GetBuffer(15));
			if (i==MAXCOUNT) abort();
            }
        while (::FindNextFile(hFind, &fd));
        }

    FindClose(hFind);
	return i;
    }


"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page