Struct qt_gui::QImageIOHandler

source ·
#[repr(C)]
pub struct QImageIOHandler { /* private fields */ }
Expand description

The QImageIOHandler class defines the common image I/O interface for all image formats in Qt.

C++ class: QImageIOHandler.

C++ documentation:

The QImageIOHandler class defines the common image I/O interface for all image formats in Qt.

Qt uses QImageIOHandler for reading and writing images through QImageReader and QImageWriter. You can also derive from this class to write your own image format handler using Qt's plugin mechanism.

Call setDevice() to assign a device to the handler, and setFormat() to assign a format to it. One QImageIOHandler may support more than one image format. canRead() returns true if an image can be read from the device, and read() and write() return true if reading or writing an image was completed successfully.

QImageIOHandler also has support for animations formats, through the functions loopCount(), imageCount(), nextImageDelay() and currentImageNumber().

In order to determine what options an image handler supports, Qt will call supportsOption() and setOption(). Make sure to reimplement these functions if you can provide support for any of the options in the ImageOption enum.

To write your own image handler, you must at least reimplement canRead() and read(). Then create a QImageIOPlugin that can create the handler. Finally, install your plugin, and QImageReader and QImageWriter will then automatically load the plugin, and start using it.

Implementations§

source§

impl QImageIOHandler

source

pub unsafe fn can_read(&self) -> bool

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.

Calls C++ function: pure virtual bool QImageIOHandler::canRead() const.

C++ documentation:

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() and QIODevice::peek().

source

pub unsafe fn current_image_number(&self) -> c_int

For image formats that support animation, this function returns the sequence number of the current image in the animation. If this function is called before any image is read(), -1 is returned. The number of the first image in the sequence is 0.

Calls C++ function: virtual int QImageIOHandler::currentImageNumber() const.

C++ documentation:

For image formats that support animation, this function returns the sequence number of the current image in the animation. If this function is called before any image is read(), -1 is returned. The number of the first image in the sequence is 0.

If the image format does not support animation, 0 is returned.

See also read().

source

pub unsafe fn current_image_rect(&self) -> CppBox<QRect>

Returns the rect of the current image. If no rect is defined for the image, and empty QRect() is returned.

Calls C++ function: virtual QRect QImageIOHandler::currentImageRect() const.

C++ documentation:

Returns the rect of the current image. If no rect is defined for the image, and empty QRect() is returned.

This function is useful for animations, where only parts of the frame may be updated at a time.

source

pub unsafe fn device(&self) -> QPtr<QIODevice>

Returns the device currently assigned to the QImageIOHandler. If not device has been assigned, 0 is returned.

Calls C++ function: QIODevice* QImageIOHandler::device() const.

C++ documentation:

Returns the device currently assigned to the QImageIOHandler. If not device has been assigned, 0 is returned.

See also setDevice().

source

pub unsafe fn format(&self) -> CppBox<QByteArray>

Returns the format that is currently assigned to QImageIOHandler. If no format has been assigned, an empty string is returned.

Calls C++ function: QByteArray QImageIOHandler::format() const.

C++ documentation:

Returns the format that is currently assigned to QImageIOHandler. If no format has been assigned, an empty string is returned.

See also setFormat().

source

pub unsafe fn image_count(&self) -> c_int

For image formats that support animation, this function returns the number of images in the animation. If the image format does not support animation, or if it is unable to determine the number of images, 0 is returned.

Calls C++ function: virtual int QImageIOHandler::imageCount() const.

C++ documentation:

For image formats that support animation, this function returns the number of images in the animation. If the image format does not support animation, or if it is unable to determine the number of images, 0 is returned.

The default implementation returns 1 if canRead() returns true; otherwise 0 is returned.

source

pub unsafe fn jump_to_image(&self, image_number: c_int) -> bool

For image formats that support animation, this function jumps to the image whose sequence number is imageNumber. The next call to read() will attempt to read this image.

Calls C++ function: virtual bool QImageIOHandler::jumpToImage(int imageNumber).

C++ documentation:

For image formats that support animation, this function jumps to the image whose sequence number is imageNumber. The next call to read() will attempt to read this image.

The default implementation does nothing, and returns false.

source

pub unsafe fn jump_to_next_image(&self) -> bool

For image formats that support animation, this function jumps to the next image.

Calls C++ function: virtual bool QImageIOHandler::jumpToNextImage().

C++ documentation:

For image formats that support animation, this function jumps to the next image.

The default implementation does nothing, and returns false.

source

pub unsafe fn loop_count(&self) -> c_int

For image formats that support animation, this function returns the number of times the animation should loop. If the image format does not support animation, 0 is returned.

Calls C++ function: virtual int QImageIOHandler::loopCount() const.

C++ documentation:

For image formats that support animation, this function returns the number of times the animation should loop. If the image format does not support animation, 0 is returned.

source

pub unsafe fn name(&self) -> CppBox<QByteArray>

Use format() instead.

Calls C++ function: virtual QByteArray QImageIOHandler::name() const.

C++ documentation:

Use format() instead.

source

pub unsafe fn next_image_delay(&self) -> c_int

For image formats that support animation, this function returns the number of milliseconds to wait until reading the next image. If the image format does not support animation, 0 is returned.

Calls C++ function: virtual int QImageIOHandler::nextImageDelay() const.

C++ documentation:

For image formats that support animation, this function returns the number of milliseconds to wait until reading the next image. If the image format does not support animation, 0 is returned.

source

pub unsafe fn option(&self, option: ImageOption) -> CppBox<QVariant>

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.

Calls C++ function: virtual QVariant QImageIOHandler::option(QImageIOHandler::ImageOption option) const.

C++ documentation:

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() and supportsOption().

source

pub unsafe fn read(&self, image: impl CastInto<Ptr<QImage>>) -> bool

Read an image from the device, and stores it in image. Returns true if the image is successfully read; otherwise returns false.

Calls C++ function: pure virtual bool QImageIOHandler::read(QImage* image).

C++ documentation:

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().

source

pub unsafe fn set_device(&self, device: impl CastInto<Ptr<QIODevice>>)

Sets the device of the QImageIOHandler to device. The image handler will use this device when reading and writing images.

Calls C++ function: void QImageIOHandler::setDevice(QIODevice* device).

C++ documentation:

Sets the device of the QImageIOHandler to device. The image handler will use this device when reading and writing images.

The device can only be set once and must be set before calling canRead(), read(), write(), etc. If you need to read multiple files, construct multiple instances of the appropriate QImageIOHandler subclass.

See also device().

source

pub unsafe fn set_format_mut(&self, format: impl CastInto<Ref<QByteArray>>)

Sets the format of the QImageIOHandler to format. The format is most useful for handlers that support multiple image formats.

Calls C++ function: void QImageIOHandler::setFormat(const QByteArray& format).

C++ documentation:

Sets the format of the QImageIOHandler to format. The format is most useful for handlers that support multiple image formats.

See also format().

source

pub unsafe fn set_format(&self, format: impl CastInto<Ref<QByteArray>>)

Sets the format of the QImageIOHandler to format. The format is most useful for handlers that support multiple image formats.

Calls C++ function: void QImageIOHandler::setFormat(const QByteArray& format) const.

C++ documentation:

Sets the format of the QImageIOHandler to format. The format is most useful for handlers that support multiple image formats.

This function is declared const so that it can be called from canRead().

See also format().

source

pub unsafe fn set_option( &self, option: ImageOption, value: impl CastInto<Ref<QVariant>> )

Sets the option option with the value value.

Calls C++ function: virtual void QImageIOHandler::setOption(QImageIOHandler::ImageOption option, const QVariant& value).

C++ documentation:

Sets the option option with the value value.

See also option() and ImageOption.

source

pub unsafe fn supports_option(&self, option: ImageOption) -> bool

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.

Calls C++ function: virtual bool QImageIOHandler::supportsOption(QImageIOHandler::ImageOption option) const.

C++ documentation:

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() and option().

source

pub unsafe fn write(&self, image: impl CastInto<Ref<QImage>>) -> bool

Writes the image image to the assigned device. Returns true on success; otherwise returns false.

Calls C++ function: virtual bool QImageIOHandler::write(const QImage& image).

C++ documentation:

Writes the image image to the assigned device. Returns true on success; otherwise returns false.

The default implementation does nothing, and simply returns false.

Trait Implementations§

source§

impl CppDeletable for QImageIOHandler

source§

unsafe fn delete(&self)

Destructs the QImageIOHandler object.

Calls C++ function: virtual [destructor] void QImageIOHandler::~QImageIOHandler().

C++ documentation:

Destructs the QImageIOHandler object.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.