Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtGui.QImageWriter Class Reference

The QImageWriter class provides a format independent interface for writing images to files or other devices. More...

Inheritance diagram for QtGui.QImageWriter:
Collaboration diagram for QtGui.QImageWriter:

Public Types

enum  ImageWriterError { DeviceError = 1, UnknownError = 0, UnsupportedFormatError = 2 }
  More...
 

Public Member Functions

 QImageWriter ()
 
 
 QImageWriter (QIODevice device, QByteArray format)
 
 
 QImageWriter (string fileName)
 
 
 QImageWriter (string fileName, QByteArray format)
 
 
virtual void CreateProxy ()
 
new bool CanWrite ()
 
 
new QImageWriter.ImageWriterError Error ()
 
 
new string ErrorString ()
 
 
new void SetText (string key, string text)
 
 
new bool SupportsOption (QImageIOHandler.ImageOption option)
 
 
new bool Write (QImage image)
 
 
new void Dispose ()
 

Static Public Member Functions

static
System.Collections.Generic.List
< QByteArray
SupportedImageFormats ()
 
 

Protected Member Functions

 QImageWriter (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

new int Compression [get, set]
 
 
new string Description [get, set]
 
 
new QIODevice Device [get, set]
 
 
new string FileName [get, set]
 
 
new QByteArray Format [get, set]
 
 
new float Gamma [get, set]
 
 
new int Quality [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

The QImageWriter class provides a format independent interface for writing images to files or other devices.

QImageWriter supports setting format specific options, such as the gamma level, compression level and quality, prior to storing the image. If you do not need such options, you can use QImage::save() or QPixmap::save() instead.

To store an image, you start by constructing a QImageWriter object. Pass either a file name or a device pointer, and the image format to QImageWriter's constructor. You can then set several options, such as the gamma level (by calling setGamma()) and quality (by calling setQuality()). canWrite() returns true if QImageWriter can write the image (i.e., the image format is supported and the device is open for writing). Call write() to write the image to the device.

If any error occurs when writing the image, write() will return false. You can then call error() to find the type of error that occurred, or errorString() to get a human readable description of what went wrong.

Call supportedImageFormats() for a list of formats that QImageWriter can write. QImageWriter supports all built-in image formats, in addition to any image format plugins that support writing.

See also QImageReader, QImageIOHandler, and QImageIOPlugin.

Member Enumeration Documentation

This enum describes errors that can occur when writing images with QImageWriter.

Enumerator:
DeviceError 

QImageWriter encountered a device error when writing the image data. Consult your device for more details on what went wrong.

UnknownError 

An unknown error occurred. If you get this value after calling write(), it is most likely caused by a bug in QImageWriter.

UnsupportedFormatError 

Qt does not support the requested image format.

Constructor & Destructor Documentation

QtGui.QImageWriter.QImageWriter ( System.Type  dummy)
protected
QtGui.QImageWriter.QImageWriter ( )

Constructs an empty QImageWriter object. Before writing, you must call setFormat() to set an image format, then setDevice() or setFileName().

QtGui.QImageWriter.QImageWriter ( QIODevice  device,
QByteArray  format 
)

Constructs a QImageWriter object using the device device and image format format.

QtGui.QImageWriter.QImageWriter ( string  fileName)

Constructs an empty QImageWriter object. Before writing, you must call setFormat() to set an image format, then setDevice() or setFileName().

QtGui.QImageWriter.QImageWriter ( string  fileName,
QByteArray  format 
)

Constructs an empty QImageWriter object. Before writing, you must call setFormat() to set an image format, then setDevice() or setFileName().

Member Function Documentation

new bool QtGui.QImageWriter.CanWrite ( )

Returns true if QImageWriter can write the image; i.e., the image format is supported and the assigned device is open for reading.

See also write(), setDevice(), and setFormat().

virtual void QtGui.QImageWriter.CreateProxy ( )
virtual
new void QtGui.QImageWriter.Dispose ( )
new QImageWriter.ImageWriterError QtGui.QImageWriter.Error ( )

Returns the type of error that last occurred.

See also ImageWriterError and errorString().

new string QtGui.QImageWriter.ErrorString ( )

Returns a human readable description of the last error that occurred.

See also error().

new void QtGui.QImageWriter.SetText ( string  key,
string  text 
)

Sets the image text associated with the key key to text. This is useful for storing copyright information or other information about the image. Example:

QImage image("some/image.jpeg");

QImageWriter writer("images/outimage.png", "png");

writer.setText("Author", "John Smith");

writer.write(image);

If you want to store a single block of data (e.g., a comment), you can pass an empty key, or use a generic key like "Description".

The key and text will be embedded into the image data after calling write().

Support for this option is implemented through QImageIOHandler::Description.

This function was introduced in Qt 4.1.

See also QImage::setText() and QImageReader::text().

static System.Collections.Generic.List<QByteArray> QtGui.QImageWriter.SupportedImageFormats ( )
static

Returns the list of image formats supported by QImageWriter.

By default, Qt can write the following formats:

FormatDescription

BMP Windows Bitmap

JPG Joint Photographic Experts Group

JPEG Joint Photographic Experts Group

PNG Portable Network Graphics

PPM Portable Pixmap

TIFF Tagged Image File Format

XBM X11 Bitmap

XPM X11 Pixmap

Reading and writing SVG files is supported through Qt's SVG Module.

Note that the QApplication instance must be created before this function is called.

See also setFormat(), QImageReader::supportedImageFormats(), and QImageIOPlugin.

new bool QtGui.QImageWriter.SupportsOption ( QImageIOHandler.ImageOption  option)

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

Different image formats support different options. Call this function to determine whether a certain option is supported by the current format. For example, the PNG format allows you to embed text into the image's metadata (see text()).

QImageWriter writer(fileName);

if (writer.supportsOption(QImageIOHandler::Description))

writer.setText("Author", "John Smith");

Options can be tested after the writer has been associated with a format.

This function was introduced in Qt 4.2.

See also QImageReader::supportsOption() and setFormat().

new bool QtGui.QImageWriter.Write ( QImage  image)

Writes the image image to the assigned device or file name. Returns true on success; otherwise returns false. If the operation fails, you can call error() to find the type of error that occurred, or errorString() to get a human readable description of the error.

See also canWrite(), error(), and errorString().

Member Data Documentation

SmokeInvocation QtGui.QImageWriter.interceptor
protected

Property Documentation

new int QtGui.QImageWriter.Compression
getset

Returns the compression of the image.

This is an image format specific function that set the compression of an image. For image formats that do not support setting the compression, this value is ignored.

The value range of compression depends on the image format. For example, the "tiff" format supports two values, 0(no compression) and 1(LZW-compression).

new string QtGui.QImageWriter.Description
getset

Use QImageReader::text() instead.

Returns the description of the image.

Use setText() instead.

This is an image format specific function that sets the description of the image to description. For image formats that do not support setting the description, this value is ignored.

The contents of description depends on the image format.

new QIODevice QtGui.QImageWriter.Device
getset

Returns the device currently assigned to QImageWriter, or 0 if no device has been assigned.

Sets QImageWriter's device to device. If a device has already been set, the old device is removed from QImageWriter and is otherwise left unchanged.

If the device is not already open, QImageWriter will attempt to open the device in QIODevice::WriteOnly mode by calling open(). Note that this does not work for certain devices, such as QProcess, QTcpSocket and QUdpSocket, where more logic is required to open the device.

new string QtGui.QImageWriter.FileName
getset

If the currently assigned device is a QFile, or if setFileName() has been called, this function returns the name of the file QImageWriter writes to. Otherwise (i.e., if no device has been assigned or the device is not a QFile), an empty QString is returned.

Sets the file name of QImageWriter to fileName. Internally, QImageWriter will create a QFile and open it in QIODevice::WriteOnly mode, and use this file when writing images.

new QByteArray QtGui.QImageWriter.Format
getset

Returns the format QImageWriter uses for writing images.

Sets the format QImageWriter will use when writing images, to format. format is a case insensitive text string. Example:

QImageWriter writer;

writer.setFormat("png"); // same as writer.setFormat("PNG");

You can call supportedImageFormats() for the full list of formats QImageWriter supports.

new float QtGui.QImageWriter.Gamma
getset

Returns the gamma level of the image.

This is an image format specific function that sets the gamma level of the image to gamma. For image formats that do not support setting the gamma level, this value is ignored.

The value range of gamma depends on the image format. For example, the "png" format supports a gamma range from 0.0 to 1.0.

new int QtGui.QImageWriter.Quality
getset

Returns the quality level of the image.

This is an image format specific function that sets the quality level of the image to quality. For image formats that do not support setting the quality, this value is ignored.

The value range of quality depends on the image format. For example, the "jpeg" format supports a quality range from 0 (low quality, high compression) to 100 (high quality, low compression).

virtual System.IntPtr QtGui.QImageWriter.SmokeObject
getset