home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright 1990 by John Wiley & Sons, Inc.
- All Rights Reserved.
- */
- /****************************************/
- /* Geometric Process Demo Program */
- /* written in Turbo C 2.0 */
- /* by */
- /* Craig A. Lindley */
- /* */
- /* Vers: 1.0 Last Update: 12/26/89 */
- /****************************************/
-
- #include <stdio.h>
- #include <conio.h>
- #include <dos.h>
- #include <alloc.h>
- #include <process.h>
- #include <graphics.h>
- #include "misc.h"
- #include "pcx.h"
- #include "vga.h"
- #include "imagesup.h"
- #include "geprocess.h"
-
- /* main geometric process program */
-
- void main(void)
- {
- char *InFileName1 = "p2c12i1a";
- char *InFileName2 = "p2c12i2a";
- char *InFileName3 = "p2c12i3a";
- char *InFileName4 = "p2c12i4a";
- char *InFileName5 = "p2c12i5a";
-
- BYTE huge *InImage;
- BYTE huge *Buffer;
- unsigned GenPCXFiles = FALSE; /* controls output file generation */
-
-
- InitGraphics();
-
- printf("Geometric Transform Example Program\n\n");
- printf("Reading the Image PCX File into memory\n");
-
- /* allocate far memory buffer for images */
- Buffer = (BYTE huge *)farcalloc(RASTERSIZE,(long)sizeof(BYTE));
-
- if (Buffer == NULL)
- {
- restorecrtmode();
- printf("Error Not enough memory for geometric operation\n");
- exit(ENoMemory);
- }
-
- /*
- Prepare image sequence p2ch12i1 - Image Magnification
- */
- if (ReadPCXFileToBuf (InFileName1,&InImage) != NoError)
- exit(ENoMemory);
-
- DisplayImageInBuf(InImage,INITVGALOADPALETTE,WAITFORKEY);
-
- /* Clear the output buffer to black. */
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,WHITE);
-
- ScaleImage(InImage,119,13,83,111,1.3,1.3,Buffer,100,25,FALSE);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i1b",8,320,200,1,320);
-
- /* Clear the output buffer to black. */
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,BLACK);
-
- ScaleImage(InImage,119,13,83,111,1.3,1.3,Buffer,100,25,TRUE);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i1c",8,320,200,1,320);
-
- farfree((BYTE far *)InImage); /* free memory */
-
- /*
- Prepare image sequence p2ch12i2 - Image Reduction
- */
- if (ReadPCXFileToBuf (InFileName2,&InImage) != NoError)
- exit(ENoMemory);
-
- DisplayImageInBuf(InImage,NOVGAINIT,WAITFORKEY);
-
- /* Clear the output buffer to black. */
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,WHITE);
-
- ScaleImage(InImage,9,76,291,105,0.5,0.5,Buffer,80,74,FALSE);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i2b",8,320,200,1,320);
-
- /* Clear the output buffer to black. */
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,WHITE);
-
- ScaleImage(InImage,9,76,291,105,0.5,0.5,Buffer,80,74,TRUE);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i2c",8,320,200,1,320);
-
- farfree((BYTE far *)InImage); /* free memory */
-
- /* Prepare image sequence p2ch12i3 Various Sized Images */
-
- if (ReadPCXFileToBuf (InFileName3,&InImage) != NoError)
- exit(ENoMemory);
-
- DisplayImageInBuf(InImage,NOVGAINIT,WAITFORKEY);
-
- /*
- Clearing the output buffer to white will show the
- boarder areas not touched by the scaling process. It also
- provides a nice white frame for the output image.
- */
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,WHITE);
-
- /* Image 1 is scaled .5 x .5 and occupies lower right corner */
- ScaleImage(InImage,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,
- 0.5,0.5,Buffer,155,95,TRUE);
-
- /* Image 2 is scaled .45 x .67 and occupies upper left corner */
- ScaleImage(InImage,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,
- 0.45,0.67,Buffer,4,4,TRUE);
-
- /* Image 3 is scaled .5 x .42 and occupies upper right corner */
- ScaleImage(InImage,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,
- 0.5,0.42,Buffer,155,4,TRUE);
-
- /* Image 4 is scaled .25 x .25 and occupies lower left corner */
- ScaleImage(InImage,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,
- 0.25,0.25,Buffer,38,145,TRUE);
-
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i3b",8,320,200,1,320);
-
- farfree((BYTE far *)InImage); /* free memory */
-
- /* Prepare image sequence p2ch12i4 - Rotated Images */
-
- if (ReadPCXFileToBuf (InFileName4,&InImage) != NoError)
- exit(ENoMemory);
-
- DisplayImageInBuf(InImage,NOVGAINIT,WAITFORKEY);
-
- /*
- Clearing the output buffer to black.
- */
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,BLACK);
-
- RotateImage(InImage,105,43,117,107,37.5,Buffer,FALSE);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i4b",8,320,200,1,320);
-
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,BLACK);
-
- RotateImage(InImage,105,43,117,107,37.5,Buffer,TRUE);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i4c",8,320,200,1,320);
-
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,BLACK);
-
- RotateImage(InImage,105,43,117,107,300.0,Buffer,FALSE);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i4d",8,320,200,1,320);
-
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,BLACK);
-
- RotateImage(InImage,105,43,117,107,300.0,Buffer,TRUE);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i4e",8,320,200,1,320);
-
- farfree((BYTE far *)InImage); /* free memory */
-
- /* Prepare image sequence p2ch12i5 - Mirrored Images */
-
- if (ReadPCXFileToBuf (InFileName5,&InImage) != NoError)
- exit(ENoMemory);
-
- DisplayImageInBuf(InImage,NOVGAINIT,WAITFORKEY);
-
- /*
- Clearing the output buffer to black.
- */
- ClearImageArea(Buffer,MINCOLNUM,MINROWNUM,MAXCOLS,MAXROWS,BLACK);
- TranslateImage(InImage,82,76,166,48,Buffer,82,10,FALSE);
- MirrorImage(InImage,82,76,166,48,HorizMirror,Buffer,82,76);
- MirrorImage(InImage,82,76,166,48,VertMirror,Buffer,82,142);
- DisplayImageInBuf(Buffer,NOVGAINIT,WAITFORKEY);
- if (GenPCXFiles)
- WritePCXFile("p2c12i5b",8,320,200,1,320);
-
- farfree((BYTE far *)InImage); /* free memory */
- farfree((BYTE far *)Buffer);
- restorecrtmode();
- closegraph();
- }