Qt 4.8
Public Functions | Static Public Functions | Properties | List of all members
QJpegHandler Class Reference

#include <qjpeghandler_p.h>

Inheritance diagram for QJpegHandler:
QImageIOHandler

Public Functions

bool canRead () const
 Returns true if an image can be read from the device (i. More...
 
QByteArray name () const
 Use format() instead. More...
 
QVariant option (ImageOption option) const
 Returns the value assigned to option as a QVariant. More...
 
 QJpegHandler ()
 
bool read (QImage *image)
 Read an image from the device, and stores it in image. More...
 
void setOption (ImageOption option, const QVariant &value)
 Sets the option option with the value value. More...
 
bool supportsOption (ImageOption option) const
 Returns true if the QImageIOHandler supports the option option; otherwise returns false. More...
 
bool write (const QImage &image)
 Writes the image image to the assigned device. More...
 
 ~QJpegHandler ()
 
- Public Functions inherited from QImageIOHandler
virtual int currentImageNumber () const
 For image formats that support animation, this function returns the sequence number of the current image in the animation. More...
 
virtual QRect currentImageRect () const
 Returns the rect of the current image. More...
 
QIODevicedevice () const
 Returns the device currently assigned to the QImageIOHandler. More...
 
QByteArray format () const
 Returns the format that is currently assigned to QImageIOHandler. More...
 
virtual int imageCount () const
 For image formats that support animation, this function returns the number of images in the animation. More...
 
virtual bool jumpToImage (int imageNumber)
 For image formats that support animation, this function jumps to the image whose sequence number is imageNumber. More...
 
virtual bool jumpToNextImage ()
 For image formats that support animation, this function jumps to the next image. More...
 
virtual int loopCount () const
 For image formats that support animation, this function returns the number of times the animation should loop. More...
 
virtual int nextImageDelay () const
 For image formats that support animation, this function returns the number of milliseconds to wait until reading the next image. More...
 
 QImageIOHandler ()
 Constructs a QImageIOHandler object. More...
 
void setDevice (QIODevice *device)
 Sets the device of the QImageIOHandler to device. More...
 
void setFormat (const QByteArray &format)
 Sets the format of the QImageIOHandler to format. More...
 
void setFormat (const QByteArray &format) const
 Sets the format of the QImageIOHandler to format. More...
 
virtual ~QImageIOHandler ()
 Destructs the QImageIOHandler object. More...
 

Static Public Functions

static bool canRead (QIODevice *device)
 

Properties

QJpegHandlerPrivated
 

Additional Inherited Members

- Public Types inherited from QImageIOHandler
enum  ImageOption {
  Size, ClipRect, Description, ScaledClipRect,
  ScaledSize, CompressionRatio, Gamma, Quality,
  Name, SubType, IncrementalReading, Endianness,
  Animation, BackgroundColor, ImageFormat
}
 This enum describes the different options supported by QImageIOHandler. More...
 
- Protected Functions inherited from QImageIOHandler
 QImageIOHandler (QImageIOHandlerPrivate &dd)
 Constructs a QImageIOHandler object, using the private member dd. More...
 
- Protected Variables inherited from QImageIOHandler
QScopedPointer< QImageIOHandlerPrivated_ptr
 

Detailed Description

Definition at line 52 of file qjpeghandler_p.h.

Constructors and Destructors

◆ QJpegHandler()

QJpegHandler::QJpegHandler ( )

Definition at line 779 of file qjpeghandler.cpp.

780  : d(new QJpegHandlerPrivate(this))
781 {
782  const uint features = qDetectCPUFeatures();
783  Q_UNUSED(features);
784 #if defined(QT_HAVE_NEON)
785  // from qimage_neon.cpp
786  Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len);
787 
788  if (features & NEON)
789  rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_neon;
790 #endif // QT_HAVE_NEON
791 #if defined(QT_HAVE_SSSE3)
792  // from qimage_ssse3.cpp
793  Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, const uchar *src, int len);
794 
795  if (features & SSSE3)
796  rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_ssse3;
797 #endif // QT_HAVE_SSSE3
798 }
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
#define QT_FASTCALL
Definition: qglobal.h:1161
unsigned char uchar
Definition: qglobal.h:994
unsigned int uint
Definition: qglobal.h:996
uint qDetectCPUFeatures()
Definition: qsimd.cpp:382
unsigned int quint32
Definition: qglobal.h:938
Definition: qsimd_p.h:222
QJpegHandlerPrivate * d
Definition: qsimd_p.h:220
static Rgb888ToRgb32Converter rgb888ToRgb32ConverterPtr
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ ~QJpegHandler()

QJpegHandler::~QJpegHandler ( )

Definition at line 800 of file qjpeghandler.cpp.

801 {
802  delete d;
803 }
QJpegHandlerPrivate * d

Functions

◆ canRead() [1/2]

bool QJpegHandler::canRead ( ) const
virtual

Returns true if an image can be read from the device (i.

e., the image format is supported, the device can be read from and the initial header information suggests that the image can be read); otherwise returns false.

When reimplementing canRead(), make sure that the I/O device (device()) is left in its original state (e.g., by using peek() rather than read()).

See also
read(), QIODevice::peek()

Implements QImageIOHandler.

Definition at line 805 of file qjpeghandler.cpp.

Referenced by QJpegPlugin::capabilities(), createReadHandlerHelper(), and read().

806 {
808  return false;
809 
811  setFormat("jpeg");
812  return true;
813  }
814 
815  return false;
816 }
void setFormat(const QByteArray &format)
Sets the format of the QImageIOHandler to format.
bool canRead() const
Returns true if an image can be read from the device (i.
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
QJpegHandlerPrivate * d

◆ canRead() [2/2]

bool QJpegHandler::canRead ( QIODevice device)
static

Definition at line 818 of file qjpeghandler.cpp.

819 {
820  if (!device) {
821  qWarning("QJpegHandler::canRead() called with no device");
822  return false;
823  }
824 
825  char buffer[2];
826  if (device->peek(buffer, 2) != 2)
827  return false;
828  return uchar(buffer[0]) == 0xff && uchar(buffer[1]) == 0xd8;
829 }
unsigned char uchar
Definition: qglobal.h:994
qint64 peek(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, without side effects (i.
Definition: qiodevice.cpp:1563
Q_CORE_EXPORT void qWarning(const char *,...)

◆ name()

QByteArray QJpegHandler::name ( ) const
virtual

Use format() instead.

Reimplemented from QImageIOHandler.

Definition at line 895 of file qjpeghandler.cpp.

896 {
897  return "jpeg";
898 }

◆ option()

QVariant QJpegHandler::option ( ImageOption  option) const
virtual

Returns the value assigned to option as a QVariant.

The type of the value depends on the option. For example, option(Size) returns a QSize variant.

See also
setOption(), supportsOption()

Reimplemented from QImageIOHandler.

Definition at line 853 of file qjpeghandler.cpp.

854 {
855  switch(option) {
856  case Quality:
857  return d->quality;
858  case ScaledSize:
859  return d->scaledSize;
860  case ScaledClipRect:
861  return d->scaledClipRect;
862  case ClipRect:
863  return d->clipRect;
864  case Size:
865  d->readJpegHeader(device());
866  return d->size;
867  case ImageFormat:
868  d->readJpegHeader(device());
869  return d->format;
870  default:
871  return QVariant();
872  }
873 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QImage::Format format
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
QJpegHandlerPrivate * d
bool readJpegHeader(QIODevice *)
QVariant option(ImageOption option) const
Returns the value assigned to option as a QVariant.

◆ read()

bool QJpegHandler::read ( QImage image)
virtual

Read an image from the device, and stores it in image.

Returns true if the image is successfully read; otherwise returns false.

For image formats that support incremental loading, and for animation formats, the image handler can assume that image points to the previous frame.

See also
canRead()

Implements QImageIOHandler.

Definition at line 831 of file qjpeghandler.cpp.

832 {
833  if (!canRead())
834  return false;
835  return d->read(image);
836 }
bool read(QImage *image)
bool canRead() const
Returns true if an image can be read from the device (i.
QJpegHandlerPrivate * d

◆ setOption()

void QJpegHandler::setOption ( ImageOption  option,
const QVariant value 
)
virtual

Sets the option option with the value value.

See also
option(), ImageOption

Reimplemented from QImageIOHandler.

Definition at line 875 of file qjpeghandler.cpp.

876 {
877  switch(option) {
878  case Quality:
879  d->quality = value.toInt();
880  break;
881  case ScaledSize:
882  d->scaledSize = value.toSize();
883  break;
884  case ScaledClipRect:
885  d->scaledClipRect = value.toRect();
886  break;
887  case ClipRect:
888  d->clipRect = value.toRect();
889  break;
890  default:
891  break;
892  }
893 }
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
QSize toSize() const
Returns the variant as a QSize if the variant has type() Size ; otherwise returns an invalid QSize...
Definition: qvariant.cpp:2432
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
QJpegHandlerPrivate * d
QVariant option(ImageOption option) const
Returns the value assigned to option as a QVariant.

◆ supportsOption()

bool QJpegHandler::supportsOption ( ImageOption  option) const
virtual

Returns true if the QImageIOHandler supports the option option; otherwise returns false.

For example, if the QImageIOHandler supports the Size option, supportsOption(Size) must return true.

See also
setOption(), option()

Reimplemented from QImageIOHandler.

Definition at line 843 of file qjpeghandler.cpp.

844 {
845  return option == Quality
846  || option == ScaledSize
847  || option == ScaledClipRect
848  || option == ClipRect
849  || option == Size
850  || option == ImageFormat;
851 }
QVariant option(ImageOption option) const
Returns the value assigned to option as a QVariant.

◆ write()

bool QJpegHandler::write ( const QImage image)
virtual

Writes the image image to the assigned device.

Returns true on success; otherwise returns false.

The default implementation does nothing, and simply returns false.

Reimplemented from QImageIOHandler.

Definition at line 838 of file qjpeghandler.cpp.

839 {
840  return write_jpeg_image(image, device(), d->quality);
841 }
static bool write_jpeg_image(const QImage &image, QIODevice *device, int sourceQuality)
QIODevice * device() const
Returns the device currently assigned to the QImageIOHandler.
QJpegHandlerPrivate * d

Properties

◆ d

QJpegHandlerPrivate* QJpegHandler::d
private

Definition at line 71 of file qjpeghandler_p.h.

Referenced by canRead(), option(), read(), setOption(), write(), and ~QJpegHandler().


The documentation for this class was generated from the following files: