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

#ifndef __IMAGEUTILS__
#define __IMAGEUTILS__

#include "MonitorUtils.h"

enum { 
	ifSelected = 0x00000001L,		// if ==> image->flags constants
	ifSelVisible = 0x00000002L,
	ifCropped = 0x00000004L,
	ifBanded = 0x00000008L,
	ifCorrupt = 0x00000010L,
	ifAborted = 0x00000020L,
	ifFull = 0x00000040L,
	ifDithered = 0x00000080L,
	ifNeedsWhiteBG = 0x00000100L,
	ifNoOnscreenProg = 0x00000200L,
	ifGWOrigSize = 0x00000400L,
	ifScreenSize = 0x00000800L,
	ifFilename = 0x00001000L,
	ifIsAboutBox = 0x00002000L,
	ifCommentsClosed = 0x00004000L,
	ifGWTempMem = 0x00008000L,
	ifNeedToRedraw = 0x00010000L
};

extern void DeferImageUpdate(ImageHandle theImage);
extern OSErr UpdateImage(ImageHandle theImage);
extern void HandleImageActivate(ImageHandle theImage, Boolean nowActive);
extern void HandleImageClick(ImageHandle theImage, EventRecord *theEvent);

ImageHandle NewImage(void);
void DisposeImage(ImageHandle theImage);
ImageHandle CopyImage(ImageHandle srcImage);
ImageHandle LastImage(void);
ImageHandle PreviousImage(ImageHandle theImage);
Boolean AnotherFull(ImageHandle theImage);
ImageHandle FindImage(WindowPtr theWindow);
void UpdateImages(MonitorHandle theMonitor);
void SetUpOnscreenPort(JVDrawParamsHandle theParams, ImageHandle theImage);
void SetUpOffscreenPort(JVDrawParamsHandle theParams, ImageHandle theImage);
OSErr DrawImage(ImageHandle theImage, short bitsFlags, NestedProgressPtr progProc);
OSErr DrawImageGWorld(ImageHandle theImage, short bitsFlags, NestedProgressPtr progProc);
OSErr DrawImageFull(ImageHandle theImage, short bitsFlags, NestedProgressPtr progProc);
void DrawFullBorder(ImageHandle theImage);
void DrawFileName(ImageHandle theImage);
Boolean MakeImageGWorld(ImageHandle theImage, Boolean quantizing);
void KillGWorld(ImageHandle theImage);
CTabHandle GetGWorldColors(ImageHandle theImage, short gwDepth);
void DoImageHelp(WindowPtr theWindow, Point globalPt);
#define FrontImage() FindImage(FWFrontWindow())
#define WinTitle(image) (*((WindowPeek)(*(image))->window)->titleHandle)
#define FileName(image) ((*(image))->file.name)
#define Cropped(image) (((*image)->flags & ifCropped) != 0)
#define Banded(image) (((*image)->flags & ifBanded) != 0)
#define Full(image) (((*image)->flags & ifFull) != 0)
#define Dithered(image) (((*image)->flags & ifDithered) != 0)
#define Corrupt(image) (((*image)->flags & ifCorrupt) != 0)
#define NeedsWhiteBG(image) (((*image)->flags & ifNeedsWhiteBG) != 0)
#define NoOnscreenProg(image) (((*image)->flags & ifNoOnscreenProg) != 0)
#define GWOrigSize(image) (((*image)->flags & ifGWOrigSize) != 0)
#define ScreenSize(image) (((*image)->flags & ifScreenSize) != 0)
#define ShowFilename(image) (((*image)->flags & ifFilename) != 0)
#define Aborted(image) (((*image)->flags & ifAborted) != 0)
#define IsAboutBox(image) (((*image)->flags & ifIsAboutBox) != 0)
#define CommentsClosed(image) (((*image)->flags & ifCommentsClosed) != 0)
#define GWTempMem(image) (((*image)->flags & ifGWTempMem) != 0)
#define NeedToRedraw(image) (((*image)->flags & ifNeedToRedraw) != 0)

#endif
