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

KImgIO

  • 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
19class RGBHandler : public QImageIOHandler
20{
21public:
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
32class RLEData : public QVector<uchar> {
33public:
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
43private:
44 uint _offset;
45};
46
47
48class RLEMap : public QMap<RLEData, uint> {
49public:
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
55private:
56 uint _counter;
57 uint _offset;
58};
59
60
61class SGIImage {
62public:
63 SGIImage(QIODevice *device);
64 ~SGIImage();
65
66 bool readImage(QImage&);
67 bool writeImage(const QImage&);
68
69private:
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
QImageIOHandler
QMap
QVector
RGBHandler
Definition: rgb.h:20
RGBHandler::read
bool read(QImage *image)
Definition: rgb.cpp:550
RGBHandler::name
QByteArray name() const
Definition: rgb.cpp:564
RGBHandler::RGBHandler
RGBHandler()
Definition: rgb.cpp:535
RGBHandler::write
bool write(const QImage &image)
Definition: rgb.cpp:557
RGBHandler::canRead
bool canRead() const
Definition: rgb.cpp:540
RLEData
Definition: rgb.h:32
RLEData::RLEData
RLEData(const uchar *d, uint l, uint o)
Definition: rgb.h:35
RLEData::offset
uint offset() const
Definition: rgb.h:41
RLEData::write
void write(QDataStream &s)
Definition: rgb.cpp:254
RLEData::operator<
bool operator<(const RLEData &) const
Definition: rgb.cpp:261
RLEData::RLEData
RLEData()
Definition: rgb.h:34
RLEMap
Definition: rgb.h:48
RLEMap::setBaseOffset
void setBaseOffset(uint o)
Definition: rgb.h:53
RLEMap::vector
QVector< const RLEData * > vector()
Definition: rgb.cpp:286
RLEMap::insert
uint insert(const uchar *d, uint l)
Definition: rgb.cpp:274
RLEMap::RLEMap
RLEMap()
Definition: rgb.h:50
SGIImage
Definition: rgb.h:61
SGIImage::readImage
bool readImage(QImage &)
Definition: rgb.cpp:149
SGIImage::writeImage
bool writeImage(const QImage &)
Definition: rgb.cpp:478
SGIImage::~SGIImage
~SGIImage()
Definition: rgb.cpp:40
uchar
quint8 uchar
Definition: dds.cpp:38
uint
quint32 uint
Definition: dds.cpp:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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