KHtml

image.h
1 /*
2  Large image displaying library.
3 
4  Copyright (C) 2004 Maks Orlovich ([email protected])
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20  AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 
23 */
24 
25 #ifndef IMAGE_H
26 #define IMAGE_H
27 
28 #include <QByteArray>
29 #include <QSize>
30 #include <QTimer>
31 #include <QPair>
32 #include <QMap>
33 
34 #include <khtml_settings.h>
35 
36 #include "imageformat.h"
37 
38 class QPainter;
39 
40 namespace khtmlImLoad
41 {
42 
43 class ImageOwner;
44 class ImageLoader;
45 class PixmapPlane;
46 
51 class Image
52 {
53 public:
59  Image(ImageOwner *owner);
60 
65  bool processData(uchar *data, int length);
66 
71  void processEOF();
72 
76  ~Image();
77 
81  QSize size() const;
82 
86  bool complete() const;
87 
91  bool hasAlpha() const;
92 
97  QImage *qimage() const;
98 
102  void setShowAnimations(KHTMLSettings::KAnimationAdvice);
103 private:
104  //Interface to the loader.
105  friend class ImageLoader;
106 
112  void notifyImageInfo(int width, int height);
113 
117  void notifyAppendFrame(int fwidth, int fheight, const ImageFormat &format);
118 
123  void notifyScanline(unsigned char version, unsigned char *data);
124 
129  void notifyQImage(unsigned char version, const QImage *image);
130 
134  void requestScanline(unsigned int lineNum, unsigned char *lineBuf);
135 
136  //### FIXME: restore the animprovider interface
137 
138 private: //Interface to the painter.
139  friend class ImagePainter;
140  bool mayPaint()
141  {
142  return original;
143  }
144  void derefSize(QSize size);
145  void refSize(QSize size);
146  PixmapPlane *getSize(QSize size);
147 
148 protected:
149  ImageOwner *owner;
150 
151  //Update reporting to owner
152  friend class Updater;
153  friend class AnimProvider;
154  bool updatesPending;
155  int updatesStartLine;
156  int updatesEndLine;
157 
158  //Incorporate the scanline into update range
159  void requestUpdate(int line);
160 
161  //Sets the state as not having updates
162  void noUpdates();
163 
167  void notifyPerformUpdate();
168 
172  void notifyFrameChange();
173 
174  //Loader stuff.
175  QByteArray bufferPreDetect;
176  ImageLoader *loader;
177  PixmapPlane *loaderPlane;
178  unsigned int loaderScanline;
179 
180  bool fullyDecoded;
181  bool inError;
182 
183  //A little helper to set the error condition.
184  void loadError();
185 
186  //Image state
187  unsigned int width, height;
188  PixmapPlane *original;
190  KHTMLSettings::KAnimationAdvice animationAdvice;
191 
192 };
193 
194 }
195 
196 #endif
bool complete() const
Returns true if the image has been fully loaded.
Definition: image.cpp:358
An image represents a static picture or an animation, that may be incrementally loaded.
Definition: image.h:51
bool hasAlpha() const
Returns true if the image may have an alpha channel.
Definition: image.cpp:476
void processEOF()
Notifies the image that the data source is exhausted, in case it cares.
Definition: image.cpp:187
A pixmap plane is responsible for drawing data of an image plane.
Definition: pixmapplane.h:41
A base class for decoders.
Definition: imageloader.h:40
QSize size() const
Returns the image&#39;s size.
Definition: image.cpp:353
An image painter let&#39;s one paint an image at the given size.
Definition: imagepainter.h:40
The updater class helps manage timers, to permit update messages to be coalesced (so we don&#39;t bug KHT...
Definition: updater.h:42
A base class for animation support.
Definition: animprovider.h:43
bool processData(uchar *data, int length)
Provides new data for decoding.
Definition: image.cpp:104
~Image()
Cleans up.
Definition: image.cpp:57
Image(ImageOwner *owner)
Creates an image with a given owner; the owner will be notified about the repaint event...
Definition: image.cpp:40
void notifyPerformUpdate()
Called by the updater when the image should tell its owners about new changes.
Definition: image.cpp:82
void notifyFrameChange()
Called when animation frame changes, requesting the owner to repaint.
Definition: image.cpp:89
void setShowAnimations(KHTMLSettings::KAnimationAdvice)
Enables or disables animations.
Definition: image.cpp:484
QImage * qimage() const
Returns the image of basic content.
Definition: image.cpp:467
The users of Image&#39;s need to inherit off ImageOwner, in order to receive the information about their ...
Definition: imageowner.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 22:44:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.