home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gsview13 / src / gvpeps.c < prev    next >
C/C++ Source or Header  |  1995-12-09  |  3KB  |  95 lines

  1. /* Copyright (C) 1993, 1994, Russell Lang.  All rights reserved.
  2.   
  3.   This file is part of GSview.
  4.   
  5.   This program is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the GSview Free Public Licence 
  9.   (the "Licence") for full details.
  10.   
  11.   Every copy of GSview must include a copy of the Licence, normally in a 
  12.   plain ASCII text file named LICENCE.  The Licence grants you the right 
  13.   to copy, modify and redistribute GSview, but only under certain conditions 
  14.   described in the Licence.  Among other things, the Licence requires that 
  15.   the copyright notice and this notice be preserved on all copies.
  16. */
  17.  
  18. /* gvpeps.c */
  19. /* EPS file manipulation module for PM GSview */
  20.  
  21. #include "gvpm.h"
  22. #include "gvceps.h"
  23.  
  24. LPBITMAP2
  25. get_bitmap()
  26. {
  27.     return (LPBITMAP2)bitmap.pbmi;
  28. }
  29.  
  30. void
  31. release_bitmap()
  32. {
  33.     /* no action for PM */
  34. }
  35.  
  36. void 
  37. make_eps_metafile(void)
  38. {
  39.     not_implemented();
  40. }
  41.  
  42. /* Write out a BMP file */
  43. void
  44. paste_to_file(void)
  45. {
  46.     LPBITMAP1 pbm1 = (LPBITMAP1)bitmap.pbmi;
  47.     BITMAPFILEHEADER2 bmfh;
  48.     UINT bmfh_length = sizeof(BITMAPFILEHEADER2) - sizeof(BITMAPINFOHEADER2);
  49.     UINT offset;
  50.     UINT length;    /* bitmap length */
  51.     ULONG fh;    /* file handle */
  52.     ULONG action;
  53.     ULONG count;
  54.     char output[MAXSTR];
  55.     strcpy(output, "*.bmp");
  56.     if (!get_filename(output, TRUE, FILTER_BMP, 0, IDS_TOPICEDIT))
  57.         return;
  58.  
  59.     bmfh.usType = 0x4d42;    /* "BM" */
  60.         if (bitmap.pbmi->cbFix == sizeof(BITMAP1)) {
  61.         offset = pbm1->bcSize + sizeof(RGB3) * dib_pal_colors((LPBITMAP2)bitmap.pbmi);
  62.         length = offset + ( dib_bytewidth((LPBITMAP2)bitmap.pbmi) * pbm1->bcHeight );
  63.     }
  64.     else {
  65.         offset = bitmap.pbmi->cbFix + sizeof(RGB2) * dib_pal_colors((LPBITMAP2)bitmap.pbmi);
  66.         length = offset + ( dib_bytewidth((LPBITMAP2)bitmap.pbmi) * bitmap.pbmi->cy );
  67.     }
  68.     bmfh.cbSize = bmfh_length + length;
  69.     bmfh.xHotspot = bmfh.yHotspot = 0;
  70.     bmfh.offBits = bmfh_length + offset;
  71.     if (DosOpen(output,    /* filename */
  72.         &fh,        /* pointer to handle */
  73.         &action,    /* pointer to result */
  74.         0,        /* initial length */
  75.         FILE_NORMAL,    /* normal file */
  76.         OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
  77.         OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYREADWRITE,
  78.         0)) {
  79.         gserror(0, "Error opening BMP file", MB_ICONEXCLAMATION, SOUND_ERROR);
  80.         return;
  81.     }
  82.     if (DosWrite(fh, (PBYTE)&bmfh, bmfh_length, &count))
  83.         gserror(0, "Error writing BMP header", MB_ICONEXCLAMATION, SOUND_ERROR);
  84.     if (DosWrite(fh, (PBYTE)bitmap.pbmi, length, &count))
  85.         gserror(0, "Error writing BMP body", MB_ICONEXCLAMATION, SOUND_ERROR);
  86.     if (DosClose(fh))
  87.         gserror(0, "Error closing BMP file", MB_ICONEXCLAMATION, SOUND_ERROR);
  88. }
  89.  
  90. void
  91. clip_convert()
  92. {
  93.     not_implemented();
  94. }
  95.