/*********************************************************/
/* This source code copyright (c) 1991-2001, Aaron Giles */
/* See the Read Me file for licensing information.       */
/* Contact email: mac@aarongiles.com                     */
/*********************************************************/

#if THINK_C
#include "THINK.Header"
#elif applec
#pragma load ":Headers:MPW.Header"
#elif __MWERKS__
//#include "MW.Header"
#else
#include "JPEGView.h"
#endif

/*
 * HandleColorChoice(theItem)
 *
 *     Purpose: Accepts menu events from the Color menu
 *      Inputs: theItem = the menu item number
 *     Returns: nothing
 *
 */
 
void HandleColorChoice(short theItem) 
{
	ImageHandle theImage = FrontImage();
	short depth;
	
	if (!theImage) return;
	depth = (*(*theImage)->dmon)->depth;
	switch (theItem) {
		case colorSysItem:
			SendNewPalette(theImage, kAEPSystem);
			break;
		case colorGrayItem:
			SendNewPalette(theImage, kAEPGrayscale);
			break;
		case colorImageItem:
			SendNewPalette(theImage, kAEPImage);
			break;
		case colorQuantItem:
			if (depth <= 8) {
				Boolean spin = !(*theImage)->qpalette || 
								((*(*theImage)->qpalette)->pmEntries != (1 << depth));
				if (spin) StartSpinning();
				SendNewPalette(theImage, kAEPQuantized);
				if (spin) StopSpinning(&qd.arrow);
			}
			break;
		case colorDitherItem:
			SendDither(theImage, !Dithered(theImage));
			break;
	}
}

/*
 * HandleQualityChoice(theItem)
 *
 *     Purpose: Accepts menu events from the Quality submenu
 *      Inputs: theItem = the menu item number
 *     Returns: nothing
 *
 */
 
void HandleQualityChoice(short theItem) 
{
	ImageHandle theImage = FrontImage();
	
	if (!theImage) return;
	switch (theItem) {
		case qualityVHighItem:
			SendQuality(theImage, kAEDQVeryHigh);
			break;
		case qualityHighItem:
			SendQuality(theImage, kAEDQHigh);
			break;
		case qualityMediumItem:
			SendQuality(theImage, kAEDQNormal);
			break;
	}
}

