/*
 * bitmap.h v1.0
 *
 * Copyright © 1994 by Stefano Reksten of 3AM - The Three Amigos!!!
 * All rights reserved.
 *
 *
 *
 * NAME
 *  CreateBitMap
 *
 * SYNOPSIS
 *  bitmap = CreateBitMap( width, height, depth )
 *
 *  struct BitMap *CreateBitMap( UWORD, UWORD, UBYTE )
 *
 * FUNCTION
 *  This function creates a bitmap of specified width, height and depth.
 *  AllocBitMap from 3.0 will be used if possible (i.e. if you have it!)
 *
 * INPUTS
 *  width, height - two numbers between 0 and 65535
 *  depth - a number between 1 and 8 (for now? :-)
 *
 * RESULTS
 *  a pointer to a BitMap structure ready to be used.
 *
 *
 * NAME
 *  DisposeBitMap
 *
 * SYNOPSIS
 *  DisposeBitMap( bitmap )
 *
 *  void DisposeBitMap( struct BitMap * )
 *
 * FUNCTION
 *  Deallocates a BitMap structure freeing each plane and the
 *  structure itself.
 *
 * INPUTS
 *  bitmap - a pointer to an usable BitMap structure
 *
 * RESULTS
 *
 *
 *
 * NAME
 *  ScaleBitMap
 *
 * SYNOPSIS
 *  success = ScaleBitMap( scaleInfo )
 *
 *  BOOL = ScaleBitMap( struct BitMapScaleInfo* )
 *
 * FUNCTION
 *  This function scales a bitmap. There is a function in kickstart 2.0+
 *  that does a similar trick but is slower, not 1.3 compatible,  can't
 *  invert horizontally or vertically the bitmap, source and destination
 *  may not overlap.
 *  To use this function you should ready a struct BitMapScaleInfo. For a
 *  complete description of this structure, see below.
 *
 * INPUTS
 *  a pointer to an initialized struct BitMapScaleInfo
 *
 * RESULTS
 *  a scaled BitMap
 *
 *
 *
 *
 * NAME
 *  CreateCTPTable
 *
 * SYNOPSIS
 *  table = CreateCTPTable( bitmap )
 *
 *  ULONG * = CreateCTPTable( struct BitMap * )
 *
 * FUNCTION
 *  This function allocates and fills with proper data a table to be
 *  used with any of the ChunkyToPlanar functions described below.
 *  Make sure you get a table before calling them!
 *  For each bitmap you want to use the latter functions on, you
 *  need one of these tables.
 *
 * INPUT
 *  a pointer to a valid BitMap structure.
 *
 * RESULTS
 *  a pointer to a table of ULONGS (you don't need to fully understand
 *  how it works, just make sure it exists)
 *
 *
 *
 *
 * NAME
 *  FreeCTPTable
 *
 * SYNOPSIS
 *  FreeCTPTable( table, bitmap )
 *
 *  void FreeCTPTable( ULONG *, struct BitMap * )
 *
 * FUNCTION
 *  Frees a table obtained from CreateCTPTable
 *
 * INPUTS the pointer returned by CreateCTPTable
 *
 * SEE ALSO
 *  CreateCTPTable(), any ChunkyToPlanar...() function
 *
 *
 *
 * NAME
 *  ChunkyToPlanar
 *  ChunkyToPlanar68020
 *
 * SYNOPSIS
 *  ChunkyToPlanar( bitmap, coord_x, coord_y, color, table )
 *  ChunkyToPlanar68020( bitmap, coord_x, coord_y, color, table )
 *
 *  void ChunkyToPlanar( struct BitMap *, UWORD, UWORD, UBYTE, ULONG * )
 *  void ChunkyToPlanar68020( struct BitMap *, UWORD, UWORD, UBYTE, ULONG * )
 *
 * FUNCTION
 *  Writes a Chunky Pixel to a bitmap. WARNING: to gain speed this
 *  function DOES NOT MAKE ANY CONTROL on the bitmap it writes on.
 *  But at least is nearly twice times faster than WritePixel.
 *  68020 version is even faster (but, if you don't have a 68020 or
 *  upper, don't use it): more than twice times WritePixel.
 *
 * INPUTS
 *  bitmap: a pointer to a valid BitMap structure
 *  coord_x, coord_y: the coordinates of the point to be written
 *  color: a valid pen number
 *  table: a table of ULONGS returned by CreateCTPTable (having passed
 *         the *SAME* bitmap)
 *
 * SEE ALSO
 *  CreateCTPTable(), ChunkyToPlanarArray68020()
 *
 *
 *
 *
 * NAME
 *  ChunkyToPlanarArray68020
 *
 * SYNOPSIS
 *  ChunkyToPlanarArray68020( bitmap, coord_x, coord_y, array,
 *                            table, width, height, arrays_pixelsPerRow )
 *
 *  void ChunkyToPlanar68020( struct BitMap *, UWORD, UWORD, UBYTE *,
 *                            ULONG *, UWORD, UWORD, UWORD )
 *
 * FUNCTION
 *  Writes an array of chunky pixels in a bitmap, specifying starting
 *  coordinates and dimensions. WARNING: to gain speed NO CONTROL is
 *  made. But at least, this function is fast.
 *
 * INPUTS
 *  bitmap: a pointer to a valid BitMap structure
 *  coord_x, coord_y: coordinates of starting point in bitmap
 *  table: a table of ULONGS returned by CreateCTPTable (having passed
 *         the *SAME* bitmap)
 *  array: an array of pen colors
 *  width, height: how many pixels will be affected.
 *  arrays_pixelsPerRow: how many pixels does a single row contain.
 *
 * BUGS:
 *  This function is (by now) for 68020 only (due to speed reasons).
 *  Starting point in the array of colors can't be specified. But it
 *  can anyway be choosen by passing (array + x * arrays_pixelsPerRow + y)
 *  where x and y are the coordinates of the starting point instead of
 *  (array).
 *
 */

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef BITMAPFUNCS_H
#define BITMAPFUNCS_H

#define BSIB_INVERTHOR    0
#define BSIB_INVERTVERT   1

#define BSIF_INVERTHOR    (1<<BSIB_INVERTHOR)
#define BSIF_INVERTVERT   (1<<BSIB_INVERTVERT)

struct BitMapScaleInfo {
	struct BitMap *bsi_SrcBitMap;      /* source BitMap                    */
	struct BitMap *bsi_DestBitMap;     /* destination BitMap               */
	struct BitMap *bsi_TempBitMap;     /* Temporary BitMap used to scale   */
	                                   /* the bitmap. If this field is set */
	                                   /* to NULL, then the function will  */
	                                   /* allocate one and release it      */
	                                   /* after having scaled the BitMap.  */
	UWORD bsi_HorNum, bsi_HorDen,      /* Numerator and denominator of the */
	                                   /* fraction the width of the BitMap */
	                                   /* will be scaled to. Each can be a */
	                                   /* number between 1 and 65535. None */
	                                   /* can be 0, or the function will   */
	                                   /* return FALSE.                    */
	      bsi_VertNum, bsi_VertDen;    /* Same as before, for the height   */
	UWORD bsi_SrcLeftEdge,             /* Left and top coordinates of the  */
	      bsi_SrcTopEdge;              /* first pixel of the source BitMap */
	UWORD bsi_DestLeftEdge,            /* Same as before, for the          */
	      bsi_DestTopEdge;             /* destination BitMap               */
	UWORD bsi_Width, bsi_Height;       /* Width and height of the BitMap   */
	UWORD bsi_Flags; };                /* There are just two flags yet:    */
	                                   /* BSIF_INVERTHOR to invert the     */
	                                   /* BitMap horizontally and          */
	                                   /* BSIF_INVERTVERT to invert it     */
	                                   /* vertically.                      */
#endif
