File: netpbm.cpp

package info (click to toggle)
kdegraphics 2%3A980312-3
  • links: PTS
  • area: contrib
  • in suites: hamm
  • size: 6,168 kB
  • ctags: 5,778
  • sloc: ansic: 26,607; cpp: 21,205; sh: 5,224; makefile: 1,651; perl: 108
file content (68 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
////////////////////////////////////////////////////
//
// Transparent support for several files formats in Qt Pixmaps,
// using the NetPBM tools.
//
// Dirk Schoenberger, Jul 1997.
//

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <qimage.h>

#define CMDBUFLEN     4096

//////
// the real filter.
//

void import_graphic (char *filter, QImageIO *image)
{
  char * tmpFileName;
  QImage myimage;

  char cmdBuf [CMDBUFLEN];

  tmpFileName = tmpnam(NULL);

  sprintf (cmdBuf, "%s %s > %s", filter, image->fileName(), tmpFileName);
//  printf (cmdBuf);
//  fflush (stdout);

  system (cmdBuf);
  myimage.load (tmpFileName);

  unlink (tmpFileName);

  image->setImage (myimage);
  image->setStatus (0);
}

//////
// PCX IO handlers for QImage.
//

void read_pcx (QImageIO *image)
{
  import_graphic ("pcxtoppm", image);
}

//////
// IFF IO handlers for QImage.
//

void read_ilbm (QImageIO *image)
{
  import_graphic ("ilbmtoppm", image);
}

//////
// TGA IO handlers for QImage.
//

void read_tga (QImageIO *image)
{
  import_graphic ("tgatoppm", image);
}