home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------*/
- /* DT , EXMOVE Feb-5, 87 */
- /* Uwe */
- /*-------------------------------------------------------------*/
-
- # include <dos.h> /* segment abd offset information */
- # include <stdio.h> /* file I/O */
- # include <conio.h> /* I/O for ports */
-
- # define MAXROWS 512 /* resolution of video frame */
- # define MAXCOLS 512
- # define MEMORYHI 0xA0
-
- unsigned char huge Buffer[MAXROWS][MAXCOLS];
- unsigned int SegBuf;
- unsigned int OffBuf;
- unsigned int MemHi;
- unsigned int MemLo;
-
-
- main()
- {
- ReadImage();
- FillBuffer(0,0,128,128,255);
- WriteImage();
- StoreImage();
- RetrieveImage();
- }
-
-
-
- /*-------------------------------------------------------------*/
- GetMoveParam(RowBuf,ColBuf)
- unsigned int RowBuf,ColBuf;
-
- {
- char far *PtrBuf;
-
- PtrBuf = &Buffer[RowBuf][ColBuf];
- SegBuf = FP_SEG(PtrBuf);
- OffBuf = FP_OFF(PtrBuf);
- MemHi = MEMORYHI + (RowBuf >> 7); /* divided by 128 */
- MemLo = OffBuf;
- }
- /*-------------------------------------------------------------*/
- ReadImage()
- {
- unsigned int i;
-
- for (i=0; i<MAXROWS; i=i+128) {
- GetMoveParam(i,0);
- ext_to_conv(SegBuf,OffBuf,MemHi,MemLo,0xFFFF);
- }
- }
- /*-------------------------------------------------------------*/
- WriteImage()
- {
- unsigned int i;
-
- for (i=0; i<MAXROWS; i=i+128) {
- GetMoveParam(i,0);
- conv_to_ext(MemHi,MemLo,SegBuf,OffBuf,0xFFFF);
- }
- }
- /*-------------------------------------------------------------*/
- FillBuffer(StartRow,StartCol,StopRow,StopCol,Value)
- unsigned int StartRow,StartCol,StopRow,StopCol;
- unsigned char Value;
-
- {
- unsigned int i,j;
- /*
- printf("\nPlease insert 5 paramaters separated by blanks");
- printf("\n/UpRow/UpCol/LoRow/LoCol/Pixel : ");
- scanf("%u %u %u %u %u",&StartRow,&StartCol,
- &StopRow,&StopCol,&Value);
- */
-
-
-
- for (i=StartRow; i<StopRow; i++) {
- for (j=StartCol; j<StopCol; j++) {
- Buffer[i][j] = Value;
- }
- }
- }
- /*-------------------------------------------------------------*/
- StoreImage()
- {
- FILE *stream;
- char Fname[20];
- unsigned char Factor;
- int i,j;
-
- /*
- printf("\nPlease insert File Name : ");
- scanf("%s",Fname);
- printf("\nPlease insert Reduction Factor : ");
- scanf("%u",&Factor);
- */
- Factor = 8;
-
- stream = fopen("Test1.dt","w");
- fputc(Factor,stream);
- for (i=0; i<512; i=i+Factor) {
- for (j=0; j<512; j=j+Factor) {
- fputc(Buffer[i][j],stream);
- }
- }
- fclose(stream);
- }
- /*-------------------------------------------------------------*/
- RetrieveImage()
- {
- FILE *stream;
- char Fname[20];
- unsigned char Factor;
- int i,j;
- /*
- printf("\nPlease insert File Name : ");
- scanf("%s",Fname);
- */
-
- stream = fopen("test1.dt","r");
- Factor = Fgetc(stream);
- printf("\nReduction Factor : %u\n",Factor);
- for (i=0; i<(512/Factor); i++) {
- for (j=0; j<(512/Factor); j++) {
- Buffer[i][j] = fgetc(stream);
- printf("%4u ",Buffer[i][j]);
- }
- }
- fclose(stream);
- }
- /*-------------------------------------------------------------*/