home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / CreativeComputers.iso / shareware / text / dvi_3.62 / source / dvisrc.lha / dlwimg.c < prev    next >
C/C++ Source or Header  |  1993-10-26  |  867b  |  37 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include "dvi.h"
  4. #include "dvilw.h"
  5.  
  6. int read_img(char *name, int x, int y, double density)
  7. {
  8.     IMG_FILE *img;
  9.     unsigned char *p;
  10.     int w,h,bytes,pw,ph;
  11.  
  12.     img = img_open(name,&w,&h,&bytes,&pw,&ph,op.img_path);
  13.     if (img==NULL) return 1;
  14.  
  15.     density = density;
  16.     psprint("gsave\n");
  17.     psprint("%d %d translate %g %g scale\n",x,y,
  18.         (double)op.hres*(double)(bytes*8)*(double)pw/25400.0,
  19.         (double)op.vres*(double)h*(double)ph/25400.0);
  20.     psprint("%d %d %d [ %d 0 0 %d 0 %d ]\n",
  21.         bytes*8,h,1,bytes*8,-h,h);
  22.     psprint("{ currentfile %d string readhexstring pop } image\n",
  23.         bytes);
  24.     while(h--)
  25.     {
  26.     int i;
  27.     p=(unsigned char*)img_read((char *)NULL,img);
  28.     for (i=0; i<bytes; i++) psprint("%02x",0xff^*p++);
  29.     pschar('\n');
  30.     }
  31.     psprint("grestore\n");
  32.  
  33.     img_close(img);
  34.     return 0;
  35. }
  36.  
  37.