Dec 132017
 
Make TP4 graphics more manageable.
File TP-GRAPH.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Make TP4 graphics more manageable.
File Name File Size Zip Size Zip Type
GRAPHICS.DOC 5836 1321 deflated
GRAPHICS.PAS 6942 1373 deflated
GRAPHICS.TPU 3984 1666 deflated

Download File TP-GRAPH.ZIP Here

Contents of the GRAPHICS.DOC file


This graphics unit for Turbo Pascal 4.0 was written and placed in the public
domain by Anthony Li.


Using the GRAPHICS unit:
------------------------

Refer for the example file GRMAKE.PAS for instructions on creating the files
FONTS.TPU and DRIVERS.TPU.


The following constants are defined for greater clarity (in my opinion) than
TP's constants:


My name for it TP's name for it
-------------- ----------------
NoGraphicsError = grOk;
GeneralGraphicsError = grError;
GraphicsDriverNotInstalled = grNoInitGraph;
GraphicsAdaptorNotDetected = grNotDetected;
GraphicsDriverFileNotFound = grFileNotFound;
InvalidGraphicsDriver = grInvalidDriver;
NotEnoughMemoryForGraphics = grNoLoadMem;
NoMemoryForScanFill = grNoScanMem;
NoMemoryForFloodFill = grNoFloodMem;
GraphicsFontFileNotFound = grFontNotFound;
NotEnoughMemoryForFont = grNoFontMem;
InvalidGraphicsFontFile = grInvalidFont;
InvalidGraphicsFontNumber = grInvalidFontNum;
GraphicsModeIsInvalid = grInvalidMode;
GraphicsIOError = grIOError;
InvalidGraphicsDevice = grInvalidDeviceNum;

LeftJustify = 0;
CenterJustify = 1;
RightJustify = 2;
BottomJustify = 0;
TopJustify = 2;
HorizontalText = 0;
VerticalText = 1;
NormalSizeText = 1;
LargestSizeText = 10;


TYPE
TypeBitImage = RECORD (* Definition of bit Images - *)
ImagePtr : Pointer; (* The ones used by GetImage *)
SizeOfImage : WORD (* and PutImage. *)
END;


VAR
GraphicsAdaptor, (* These variables are updated as *)
GraphicsMode : INTEGER; (* the graphics environment is *)
LastGraphicsErrorCode : INTEGER; (* initialized and manipulated. *)

(*-------------------------------------------------------------------------*)
PROCEDURE EnterGraphicsMode ( GraphicsAdaptorToTry,
GraphicsModeToTry : INTEGER);

Attempts to use the graphics mode for the given graphics adaptor.
Check the variable LastGraphicsErrorCode to see if the attempt
was successful.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE ExitGraphicsMode;

Exits graphics mode and returns to text mode.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE SelectFont ( FontNumber,
Direction,
SizeFactor,
HorizontalJustification,
VerticalJustification : INTEGER);

Sets the current font for use with OutText, OutTextXY, etc.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE GetBitImage (VAR ImageHolder : TypeBitImage;
LeftColumn,
TopRow,
RightColumn,
BottomRow : INTEGER);

Gets a bit image from the screen. Works like TP's GetImage, but this
is easier to use.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE PutBitImage (VAR ImageToShow : TypeBitImage;
LeftColumn,
TopRow,
BitMask : INTEGER);

Writes a bit image onto the screen. Works like TP's PutImage.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE ReleaseBitImageMemory (VAR ImageToKill : TypeBitImage);

"Kills" a bit image, releasing the memory that it used.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE ResetBitImageFile (VAR BitImageFile : FILE;
Filename : STRING);

Opens a file for reading bit images.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE RewriteBitImageFile (VAR BitImageFile : FILE;
Filename : STRING);

Opens a file for writing bit images.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE WriteBitImageToFile (VAR TargetFile : FILE;
VAR ImageToWrite : TypeBitImage);

Writes a bit image to a bit image file that is already open.
(*-------------------------------------------------------------------------*)


(*-------------------------------------------------------------------------*)
PROCEDURE ReadBitImageFromFile (VAR SourceFile : FILE;
VAR ImageHolder : TypeBitImage);

Reads a bit image from an open bit image file to a bit image.
(*-------------------------------------------------------------------------*)



 December 13, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)