Struct qt_gui::QPictureIO

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

The QPictureIO class contains parameters for loading and saving pictures.

C++ class: QPictureIO.

C++ documentation:

The QPictureIO class contains parameters for loading and saving pictures.

QPictureIO contains a QIODevice object that is used for picture data I/O. The programmer can install new picture file formats in addition to those that Qt provides.

You don't normally need to use this class; QPicture::load(), QPicture::save().

Implementations§

source§

impl QPictureIO

source

pub unsafe fn define_io_handler( format: *const c_char, header: *const c_char, flags: *const c_char, read_picture: Option<extern "C" fn(_: *mut QPictureIO)>, write_picture: Option<extern "C" fn(_: *mut QPictureIO)> )

Defines a picture I/O handler for the picture format called format, which is recognized using the regular expression defined in header, read using readPicture and written using writePicture.

Calls C++ function: static void QPictureIO::defineIOHandler(const char* format, const char* header, const char* flags, void (*FN_PTR)(QPictureIO *) read_picture, void (*FN_PTR)(QPictureIO *) write_picture).

C++ documentation:

Defines a picture I/O handler for the picture format called format, which is recognized using the regular expression defined in header, read using readPicture and written using writePicture.

flags is a string of single-character flags for this format. The only flag defined currently is T (upper case), so the only legal value for flags are "T" and the empty string. The "T" flag means that the picture file is a text file, and Qt should treat all newline conventions as equivalent. (XPM files and some PPM files are text files for example.)

format is used to select a handler to write a QPicture; header is used to select a handler to read an picture file.

If readPicture is a null pointer, the QPictureIO will not be able to read pictures in format. If writePicture is a null pointer, the QPictureIO will not be able to write pictures in format. If both are null, the QPictureIO object is valid but useless.

Example:

void readSVG(QPictureIO *picture) { // read the picture using the picture->ioDevice() }

void writeSVG(QPictureIO *picture) { // write the picture using the picture->ioDevice() }

// add the SVG picture handler // …

Before the regular expression test, all the 0 bytes in the file header are converted to 1 bytes. This is done because when Qt was ASCII-based, QRegExp could not handle 0 bytes in strings.

The regexp is only applied on the first 14 bytes of the file.

(Note that if one handlerIO supports writing a format and another supports reading it, Qt supports both reading and writing. If two handlers support the same operation, Qt chooses one arbitrarily.)

source

pub unsafe fn description(&self) -> CppBox<QString>

Returns the picture description string.

Calls C++ function: QString QPictureIO::description() const.

C++ documentation:

Returns the picture description string.

See also setDescription().

source

pub unsafe fn file_name(&self) -> CppBox<QString>

Returns the file name currently set.

Calls C++ function: QString QPictureIO::fileName() const.

C++ documentation:

Returns the file name currently set.

See also setFileName().

source

pub unsafe fn format(&self) -> *const c_char

Returns the picture format string or 0 if no format has been explicitly set.

Calls C++ function: const char* QPictureIO::format() const.

C++ documentation:

Returns the picture format string or 0 if no format has been explicitly set.

See also setFormat().

source

pub unsafe fn gamma(&self) -> c_float

Returns the gamma value at which the picture will be viewed.

Calls C++ function: float QPictureIO::gamma() const.

C++ documentation:

Returns the gamma value at which the picture will be viewed.

See also setGamma().

source

pub unsafe fn input_formats() -> CppBox<QListOfQByteArray>

Returns a sorted list of picture formats that are supported for picture input.

Calls C++ function: static QList<QByteArray> QPictureIO::inputFormats().

C++ documentation:

Returns a sorted list of picture formats that are supported for picture input.

source

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

Returns the IO device currently set.

Calls C++ function: QIODevice* QPictureIO::ioDevice() const.

C++ documentation:

Returns the IO device currently set.

See also setIODevice().

source

pub unsafe fn new() -> CppBox<QPictureIO>

Constructs a QPictureIO object with all parameters set to zero.

Calls C++ function: [constructor] void QPictureIO::QPictureIO().

C++ documentation:

Constructs a QPictureIO object with all parameters set to zero.

source

pub unsafe fn from_q_io_device_char( io_device: impl CastInto<Ptr<QIODevice>>, format: *const c_char ) -> CppBox<QPictureIO>

Constructs a QPictureIO object with the I/O device ioDevice and a format tag.

Calls C++ function: [constructor] void QPictureIO::QPictureIO(QIODevice* ioDevice, const char* format).

C++ documentation:

Constructs a QPictureIO object with the I/O device ioDevice and a format tag.

source

pub unsafe fn from_q_string_char( file_name: impl CastInto<Ref<QString>>, format: *const c_char ) -> CppBox<QPictureIO>

Constructs a QPictureIO object with the file name fileName and a format tag.

Calls C++ function: [constructor] void QPictureIO::QPictureIO(const QString& fileName, const char* format).

C++ documentation:

Constructs a QPictureIO object with the file name fileName and a format tag.

source

pub unsafe fn output_formats() -> CppBox<QListOfQByteArray>

Returns a sorted list of picture formats that are supported for picture output.

Calls C++ function: static QList<QByteArray> QPictureIO::outputFormats().

C++ documentation:

Returns a sorted list of picture formats that are supported for picture output.

source

pub unsafe fn parameters(&self) -> *const c_char

Returns the picture's parameters string.

Calls C++ function: const char* QPictureIO::parameters() const.

C++ documentation:

Returns the picture’s parameters string.

See also setParameters().

source

pub unsafe fn picture(&self) -> Ref<QPicture>

Returns the picture currently set.

Calls C++ function: const QPicture& QPictureIO::picture() const.

C++ documentation:

Returns the picture currently set.

See also setPicture().

source

pub unsafe fn picture_format_q_string( file_name: impl CastInto<Ref<QString>> ) -> CppBox<QByteArray>

Returns a string that specifies the picture format of the file fileName, or null if the file cannot be read or if the format is not recognized.

Calls C++ function: static QByteArray QPictureIO::pictureFormat(const QString& fileName).

C++ documentation:

Returns a string that specifies the picture format of the file fileName, or null if the file cannot be read or if the format is not recognized.

source

pub unsafe fn picture_format_q_io_device( arg1: impl CastInto<Ptr<QIODevice>> ) -> CppBox<QByteArray>

This is an overloaded function.

Calls C++ function: static QByteArray QPictureIO::pictureFormat(QIODevice* arg1).

C++ documentation:

This is an overloaded function.

Returns a string that specifies the picture format of the picture read from IO device d, or 0 if the device cannot be read or if the format is not recognized.

Make sure that d is at the right position in the device (for example, at the beginning of the file).

See also QIODevice::pos().

source

pub unsafe fn quality(&self) -> c_int

Returns the quality of the written picture, related to the compression ratio.

Calls C++ function: int QPictureIO::quality() const.

C++ documentation:

Returns the quality of the written picture, related to the compression ratio.

See also setQuality() and QPicture::save().

source

pub unsafe fn read(&self) -> bool

Reads an picture into memory and returns true if the picture was successfully read; otherwise returns false.

Calls C++ function: bool QPictureIO::read().

C++ documentation:

Reads an picture into memory and returns true if the picture was successfully read; otherwise returns false.

Before reading an picture you must set an IO device or a file name. If both an IO device and a file name have been set, the IO device will be used.

Setting the picture file format string is optional.

Note that this function does not set the format used to read the picture. If you need that information, use the pictureFormat() static functions.

Example:

QPictureIO iio; QPixmap pixmap; iio.setFileName(“vegeburger.pic”); if (iio.read()) { // OK QPicture picture = iio.picture(); QPainter painter(&pixmap); painter.drawPicture(0, 0, picture); }

See also setIODevice(), setFileName(), setFormat(), write(), and QPixmap::load().

source

pub unsafe fn set_description(&self, arg1: impl CastInto<Ref<QString>>)

Sets the picture description string for picture handlers that support picture descriptions to description.

Calls C++ function: void QPictureIO::setDescription(const QString& arg1).

C++ documentation:

Sets the picture description string for picture handlers that support picture descriptions to description.

Currently, no picture format supported by Qt uses the description string.

See also description().

source

pub unsafe fn set_file_name(&self, arg1: impl CastInto<Ref<QString>>)

Sets the name of the file to read or write an picture from to fileName.

Calls C++ function: void QPictureIO::setFileName(const QString& arg1).

C++ documentation:

Sets the name of the file to read or write an picture from to fileName.

See also fileName() and setIODevice().

source

pub unsafe fn set_format(&self, arg1: *const c_char)

Sets the picture format to format for the picture to be read or written.

Calls C++ function: void QPictureIO::setFormat(const char* arg1).

C++ documentation:

Sets the picture format to format for the picture to be read or written.

It is necessary to specify a format before writing an picture, but it is not necessary to specify a format before reading an picture.

If no format has been set, Qt guesses the picture format before reading it. If a format is set the picture will only be read if it has that format.

See also read(), write(), and format().

source

pub unsafe fn set_gamma(&self, arg1: c_float)

Sets the gamma value at which the picture will be viewed to gamma. If the picture format stores a gamma value for which the picture is intended to be used, then this setting will be used to modify the picture. Setting to 0.0 will disable gamma correction (i.e. any specification in the file will be ignored).

Calls C++ function: void QPictureIO::setGamma(float arg1).

C++ documentation:

Sets the gamma value at which the picture will be viewed to gamma. If the picture format stores a gamma value for which the picture is intended to be used, then this setting will be used to modify the picture. Setting to 0.0 will disable gamma correction (i.e. any specification in the file will be ignored).

The default value is 0.0.

See also gamma().

source

pub unsafe fn set_io_device(&self, arg1: impl CastInto<Ptr<QIODevice>>)

Sets the IO device to be used for reading or writing an picture.

Calls C++ function: void QPictureIO::setIODevice(QIODevice* arg1).

C++ documentation:

Sets the IO device to be used for reading or writing an picture.

Setting the IO device allows pictures to be read/written to any block-oriented QIODevice.

If ioDevice is not null, this IO device will override file name settings.

See also setFileName().

source

pub unsafe fn set_parameters(&self, arg1: *const c_char)

Sets the picture's parameter string to parameters. This is for picture handlers that require special parameters.

Calls C++ function: void QPictureIO::setParameters(const char* arg1).

C++ documentation:

Sets the picture’s parameter string to parameters. This is for picture handlers that require special parameters.

Although the current picture formats supported by Qt ignore the parameters string, it may be used in future extensions or by contributions (for example, JPEG).

See also parameters().

source

pub unsafe fn set_picture(&self, arg1: impl CastInto<Ref<QPicture>>)

Sets the picture to picture.

Calls C++ function: void QPictureIO::setPicture(const QPicture& arg1).

C++ documentation:

Sets the picture to picture.

See also picture().

source

pub unsafe fn set_quality(&self, arg1: c_int)

Sets the quality of the written picture to q, related to the compression ratio.

Calls C++ function: void QPictureIO::setQuality(int arg1).

C++ documentation:

Sets the quality of the written picture to q, related to the compression ratio.

q must be in the range -1..100. Specify 0 to obtain small compressed files, 100 for large uncompressed files. (-1 signifies the default compression.)

See also quality() and QPicture::save().

source

pub unsafe fn set_status(&self, arg1: c_int)

Sets the picture IO status to status. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.

Calls C++ function: void QPictureIO::setStatus(int arg1).

C++ documentation:

Sets the picture IO status to status. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.

See also status().

source

pub unsafe fn status(&self) -> c_int

Returns the picture's IO status. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.

Calls C++ function: int QPictureIO::status() const.

C++ documentation:

Returns the picture’s IO status. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.

See also setStatus().

source

pub unsafe fn write(&self) -> bool

Writes an picture to an IO device and returns true if the picture was successfully written; otherwise returns false.

Calls C++ function: bool QPictureIO::write().

C++ documentation:

Writes an picture to an IO device and returns true if the picture was successfully written; otherwise returns false.

Before writing an picture you must set an IO device or a file name. If both an IO device and a file name have been set, the IO device will be used.

The picture will be written using the specified picture format.

Example:

QPictureIO iio; QPicture picture; QPainter painter(&picture); painter.drawPixmap(0, 0, pixmap); iio.setPicture(picture); iio.setFileName(“vegeburger.pic”); iio.setFormat(“PIC”); if (iio.write()) return true; // returned true if written successfully

See also setIODevice(), setFileName(), setFormat(), read(), and QPixmap::save().

Trait Implementations§

source§

impl CppDeletable for QPictureIO

source§

unsafe fn delete(&self)

Destroys the object and all related data.

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

C++ documentation:

Destroys the object and all related data.

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.