• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KImgIO

  • sources
  • kde-4.14
  • kdelibs
  • kimgio
rgb.h
Go to the documentation of this file.
1 // kimgio module for SGI images
2 //
3 // Copyright (C) 2004 Melchior FRANZ <mfranz@kde.org>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the Lesser GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 
10 #ifndef KIMG_RGB_H
11 #define KIMG_RGB_H
12 
13 
14 #include <QtGui/QImageIOPlugin>
15 #include <QtCore/QMap>
16 #include <QtCore/QVector>
17 
18 
19 class RGBHandler : public QImageIOHandler
20 {
21 public:
22  RGBHandler();
23 
24  bool canRead() const;
25  bool read(QImage *image);
26  bool write(const QImage &image);
27  QByteArray name() const;
28  static bool canRead(QIODevice *device);
29 };
30 
31 
32 class RLEData : public QVector<uchar> {
33 public:
34  RLEData() {}
35  RLEData(const uchar *d, uint l, uint o) : _offset(o) {
36  for (uint i = 0; i < l; i++)
37  append(d[i]);
38  }
39  bool operator<(const RLEData&) const;
40  void write(QDataStream& s);
41  uint offset() const { return _offset; }
42 
43 private:
44  uint _offset;
45 };
46 
47 
48 class RLEMap : public QMap<RLEData, uint> {
49 public:
50  RLEMap() : _counter(0), _offset(0) {}
51  uint insert(const uchar *d, uint l);
52  QVector<const RLEData*> vector();
53  void setBaseOffset(uint o) { _offset = o; }
54 
55 private:
56  uint _counter;
57  uint _offset;
58 };
59 
60 
61 class SGIImage {
62 public:
63  SGIImage(QIODevice *device);
64  ~SGIImage();
65 
66  bool readImage(QImage&);
67  bool writeImage(const QImage&);
68 
69 private:
70  enum { NORMAL, DITHERED, SCREEN, COLORMAP }; // colormap
71  QIODevice *_dev;
72  QDataStream _stream;
73 
74  quint8 _rle;
75  quint8 _bpc;
76  quint16 _dim;
77  quint16 _xsize;
78  quint16 _ysize;
79  quint16 _zsize;
80  quint32 _pixmin;
81  quint32 _pixmax;
82  char _imagename[80];
83  quint32 _colormap;
84 
85  quint32 *_starttab;
86  quint32 *_lengthtab;
87  QByteArray _data;
88  QByteArray::Iterator _pos;
89  RLEMap _rlemap;
90  QVector<const RLEData*> _rlevector;
91  uint _numrows;
92 
93  bool readData(QImage&);
94  bool getRow(uchar *dest);
95 
96  void writeHeader();
97  void writeRle();
98  void writeVerbatim(const QImage&);
99  bool scanData(const QImage&);
100  uint compact(uchar *, uchar *);
101  uchar intensity(uchar);
102 };
103 
104 #endif
105 
QIODevice
QImageIOHandler::device
QIODevice * device() const
QVector< uchar >::append
void append(const T &value)
QByteArray
RLEMap::insert
uint insert(const uchar *d, uint l)
Definition: rgb.cpp:274
RLEData::write
void write(QDataStream &s)
Definition: rgb.cpp:254
QDataStream
RLEMap::RLEMap
RLEMap()
Definition: rgb.h:50
QMap
RGBHandler
Definition: rgb.h:19
RGBHandler::read
bool read(QImage *image)
Definition: rgb.cpp:550
RLEData::offset
uint offset() const
Definition: rgb.h:41
RGBHandler::name
QByteArray name() const
Definition: rgb.cpp:564
SGIImage
Definition: rgb.h:61
RLEData
Definition: rgb.h:32
SGIImage::SGIImage
SGIImage(QIODevice *device)
Definition: rgb.cpp:31
RLEMap
Definition: rgb.h:48
RLEData::RLEData
RLEData(const uchar *d, uint l, uint o)
Definition: rgb.h:35
QImageIOHandler
RLEMap::vector
QVector< const RLEData * > vector()
Definition: rgb.cpp:286
RGBHandler::write
bool write(const QImage &image)
Definition: rgb.cpp:557
RLEMap::setBaseOffset
void setBaseOffset(uint o)
Definition: rgb.h:53
uchar
quint8 uchar
Definition: dds.cpp:38
QImage
QVector
SGIImage::~SGIImage
~SGIImage()
Definition: rgb.cpp:40
RGBHandler::canRead
bool canRead() const
Definition: rgb.cpp:540
RLEData::RLEData
RLEData()
Definition: rgb.h:34
RGBHandler::RGBHandler
RGBHandler()
Definition: rgb.cpp:535
uint
quint32 uint
Definition: dds.cpp:36
RLEData::operator<
bool operator<(const RLEData &) const
Definition: rgb.cpp:261
SGIImage::writeImage
bool writeImage(const QImage &)
Definition: rgb.cpp:478
SGIImage::readImage
bool readImage(QImage &)
Definition: rgb.cpp:149
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KImgIO

Skip menu "KImgIO"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal