<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # QImageWriter Class Reference ## [[QtGui](index.htm) module] 該QImageWriter類提供用于編寫圖像文件或其它設備的格式無關的接口。[More...](#details) ### Types * `enum ImageWriterError { UnknownError, DeviceError, UnsupportedFormatError }` ### Methods * `__init__ (self)` * `__init__ (self, QIODevice?device, QByteArray?format)` * `__init__ (self, QString?fileName, QByteArray?format?=?QByteArray())` * `bool canWrite (self)` * `int compression (self)` * `QString description (self)` * `QIODevice device (self)` * `ImageWriterError error (self)` * `QString errorString (self)` * `QString fileName (self)` * `QByteArray format (self)` * `float gamma (self)` * `int quality (self)` * `setCompression (self, int?compression)` * `setDescription (self, QString?description)` * `setDevice (self, QIODevice?device)` * `setFileName (self, QString?fileName)` * `setFormat (self, QByteArray?format)` * `setGamma (self, float?gamma)` * `setQuality (self, int?quality)` * `setText (self, QString?key, QString?text)` * `bool supportsOption (self, QImageIOHandler.ImageOption?option)` * `bool write (self, QImage?image)` ### Static Methods * `list-of-QByteArray supportedImageFormats ()` * * * ## Detailed Description 該QImageWriter類提供用于編寫圖像文件或其它設備的格式無關的接口。 QImageWriter支持設置格式特定的選項,如Gamma值,壓縮水平和質量,在存儲圖像前。如果你不需要這樣的選項,您可以使用[QImage.save](qimage.html#save)()或[QPixmap.save](qpixmap.html#save)( )來代替。 要存儲的圖像,你通過構建一個QImageWriter對象開始。通過其中一個文件名或設備指針,圖像格式QImageWriter的構造函數。然后,您可以設置多個選項,如伽瑪值(通過調用[setGamma](qimagewriter.html#setGamma)( ) )和質量(通過調用[setQuality](qimagewriter.html#setQuality)())。[canWrite](qimagewriter.html#canWrite)( )返回True ,如果QImageWriter可寫的圖像(即圖像格式的支持和設備是開放的寫作) 。通話[write](qimagewriter.html#write)( )將圖像寫入到設備。 如果寫入圖像時出現任何錯誤,[write](qimagewriter.html#write)( )將返回False 。然后,您可以調用[error](qimagewriter.html#error)()找到所發生的錯誤的類型,或者[errorString](qimagewriter.html#errorString)()來得到一個什么地方出了錯人類可讀的描述。 Call [supportedImageFormats](qimagewriter.html#supportedImageFormats)( )對于格式QImageWriter可以寫一個清單。 QImageWriter支持所有內置的圖像格式,除了支持寫入任何圖像格式的插件。 * * * ## Type Documentation ``` QImageWriter.ImageWriterError ``` 這個枚舉變量描述了編寫圖像時可能發生的錯誤[QImageWriter](qimagewriter.html)。 | Constant | Value | Description | | --- | --- | --- | | `QImageWriter.DeviceError` | `1` | [QImageWriter](qimagewriter.html)寫入圖像數據時遇到的一個裝置的錯誤。請諮詢您的設備上出了什么問題的更多細節。 | | `QImageWriter.UnsupportedFormatError` | `2` | Qt不支持所請求的圖像的格式。 | | `QImageWriter.UnknownError` | `0` | 發生未知錯誤。如果在調用后得到這個值[write](qimagewriter.html#write)( ) ,它是最有可能的一個錯誤引起的[QImageWriter](qimagewriter.html)。 | * * * ## Method Documentation ``` QImageWriter.__init__ (self) ``` 構造一個空[QImageWriter](qimagewriter.html)對象。寫作之前,你必須調用[setFormat](qimagewriter.html#setFormat)()來設置圖像格式,然后[setDevice](qimagewriter.html#setDevice)()或[setFileName](qimagewriter.html#setFileName)( ) 。 ``` QImageWriter.__init__ (self, QIODevice?device, QByteArray?format) ``` 構造一個[QImageWriter](qimagewriter.html)使用該設備對象_device_和圖像格式_format_。 ``` QImageWriter.__init__ (self, QString?fileName, QByteArray?format?=?QByteArray()) ``` 構造一個[QImageWriter](qimagewriter.html)這將寫入一個文件名為對象_fileName_使用的圖像格式_format_。如果_format_不設置,[QImageWriter](qimagewriter.html)將檢測到的圖像格式通過檢查的延伸_fileName_。 ``` bool QImageWriter.canWrite (self) ``` 返回True如果[QImageWriter](qimagewriter.html)可以寫的圖像,也就是說,圖像格式的支持以及分配的裝置打開閱讀。 **See also** [write](qimagewriter.html#write)( )[setDevice](qimagewriter.html#setDevice)()和[setFormat](qimagewriter.html#setFormat)( ) 。 ``` int QImageWriter.compression (self) ``` 返回圖像的壓縮。 **See also** [setCompression](qimagewriter.html#setCompression)( ) 。 ``` QString QImageWriter.description (self) ``` ``` QIODevice QImageWriter.device (self) ``` [](qiodevice.html) [返回當前分配給設備](qiodevice.html)[QImageWriter](qimagewriter.html),或者0,如果沒有設備已經被分配。 **See also** [setDevice](qimagewriter.html#setDevice)( ) 。 ``` ImageWriterError QImageWriter.error (self) ``` [ 返回上次發生錯誤的類型。 ](qimagewriter.html#ImageWriterError-enum) [**See also**](qimagewriter.html#ImageWriterError-enum) [ImageWriterError](qimagewriter.html#ImageWriterError-enum)和[errorString](qimagewriter.html#errorString)( ) 。 ``` QString QImageWriter.errorString (self) ``` 返回上次發生錯誤的可讀描述。 **See also** [error](qimagewriter.html#error)( ) 。 ``` QString QImageWriter.fileName (self) ``` 如果當前分配裝置是[QFile](qfile.html),或者如果[setFileName](qimagewriter.html#setFileName)( )被調用,此函數返回文件的名稱[QImageWriter](qimagewriter.html)寫入。否則(即,如果沒有設備已被分配或設備不是[QFile](qfile.html)) ,空[QString](qstring.html)返回。 **See also** [setFileName](qimagewriter.html#setFileName)()和[setDevice](qimagewriter.html#setDevice)( ) 。 ``` QByteArray QImageWriter.format (self) ``` [](qbytearray.html) [返回格式](qbytearray.html)[QImageWriter](qimagewriter.html)用來書寫的圖像。 **See also** [setFormat](qimagewriter.html#setFormat)( ) 。 ``` float QImageWriter.gamma (self) ``` 返回圖像的灰度級。 **See also** [setGamma](qimagewriter.html#setGamma)( ) 。 ``` int QImageWriter.quality (self) ``` 返回的圖像的質量級別。 **See also** [setQuality](qimagewriter.html#setQuality)( ) 。 ``` QImageWriter.setCompression (self, int?compression) ``` 這是設置一個圖像的壓縮圖像格式的具體功能。對于不支持設置壓縮圖像格式,該值將被忽略。 的取值范圍_compression_取決于圖像格式。例如, “ TIFF ”格式支持兩個值, 0 (不壓縮)和1( LZW壓縮) 。 **See also** [compression](qimagewriter.html#compression)( ) 。 ``` QImageWriter.setDescription (self, QString?description) ``` ``` QImageWriter.setDevice (self, QIODevice?device) ``` Sets [QImageWriter](qimagewriter.html)的設備_device_。如果設備已經被設置,舊設備是從除去[QImageWriter](qimagewriter.html)而在其他情況保持不變。 如果該設備尚未打開,[QImageWriter](qimagewriter.html)將嘗試在打開設備[QIODevice.WriteOnly](qiodevice.html#OpenModeFlag-enum)模式通過調用open ( ) 。注意,這并不對某些設備,如工作[QProcess](qprocess.html),[QTcpSocket](qtcpsocket.html)和[QUdpSocket](qudpsocket.html),其中更多的邏輯需要打開設備。 **See also** [device](qimagewriter.html#device)()和[setFileName](qimagewriter.html#setFileName)( ) 。 ``` QImageWriter.setFileName (self, QString?fileName) ``` 設置的文件名[QImageWriter](qimagewriter.html)至_fileName_。在內部,[QImageWriter](qimagewriter.html)將創建一個[QFile](qfile.html)并在打開它[QIODevice.WriteOnly](qiodevice.html#OpenModeFlag-enum)模式,并寫入圖像時使用這個文件。 **See also** [fileName](qimagewriter.html#fileName)()和[setDevice](qimagewriter.html#setDevice)( ) 。 ``` QImageWriter.setFormat (self, QByteArray?format) ``` 設置格式[QImageWriter](qimagewriter.html)寫圖像時,要會用_format_。_format_是不區分大小寫的文本字符串。例如: ``` [QImageWriter](qimagewriter.html) writer; writer.setFormat("png"); // same as writer.setFormat("PNG"); ``` 您可以致電[supportedImageFormats](qimagewriter.html#supportedImageFormats)( )對于格式的完整列表[QImageWriter](qimagewriter.html)支持。 **See also** [format](qimagewriter.html#format)( ) 。 ``` QImageWriter.setGamma (self, float?gamma) ``` 這是一種圖像格式的具體功能,用于設置圖像的伽馬電平到_gamma_。對于不支持設置的Gamma值的圖像格式,該值將被忽略。 的取值范圍_gamma_取決于圖像格式。例如, “ PNG ”格式支持一個伽瑪范圍從0.0到1.0。 **See also** [gamma](qimagewriter.html#gamma)()和[quality](qimagewriter.html#quality)( ) 。 ``` QImageWriter.setQuality (self, int?quality) ``` 這是一種圖像格式的具體功能,用于設置圖像的質量水平來_quality_。對于不支持設置質量的圖像格式,該值將被忽略。 的取值范圍_quality_取決于圖像格式。例如, “JPEG”格式支持的質量范圍從0(低品質,高壓縮)到100 (高品質,低壓縮率) 。 **See also** [quality](qimagewriter.html#quality)( ) 。 ``` QImageWriter.setText (self, QString?key, QString?text) ``` 設置與該鍵關聯圖像的文字_key_至_text_。這是用于存儲版權信息或圖像等信息是有用的。例如: ``` [QImage](qimage.html) image("some/image.jpeg"); [QImageWriter](qimagewriter.html) writer("../img/outimage.png", "png"); writer.setText("Author", "John Smith"); writer.write(image); ``` 如果你想存儲數據的一個單一的塊(例如,注釋) ,你可以傳遞一個空鍵,或使用如“描述”一個通用密鑰。 鍵和文本將被嵌入到圖像數據后調用[write](qimagewriter.html#write)( ) 。 支持這個選項是通過實施[QImageIOHandler.Description](qimageiohandler.html#ImageOption-enum)。 這個函數是Qt 4.1中引入。 **See also** [QImage.setText](qimage.html#setText)()和[QImageReader.text](qimagereader.html#text)( ) 。 ``` list-of-QByteArray QImageWriter.supportedImageFormats () ``` 傳回的圖像格式所支持的列表[QImageWriter](qimagewriter.html)。 默認情況下, Qt可以編寫以下格式: | Format | Description | | --- | --- | | 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 | 讀取和寫入SVG文件是通過Qt的支持[SVG Module](index.htm)。 注意,這個[QApplication](qapplication.html)實例必須調用此函數之前創建。 **See also** [setFormat](qimagewriter.html#setFormat)( )[QImageReader.supportedImageFormats](qimagereader.html#supportedImageFormats)()和[QImageIOPlugin](index.htm)。 ``` bool QImageWriter.supportsOption (self, QImageIOHandler.ImageOption?option) ``` 返回True如果writer支持_option_否則返回False 。 不同的圖像格式支持不同的選項。調用此函數來判斷某個選項是否支持當前格式。例如, PNG格式允許你嵌入文本到圖像的元數據(見正文( ) ) 。 ``` [QImageWriter](qimagewriter.html) writer(fileName); if (writer.supportsOption([QImageIOHandler](qimageiohandler.html).Description)) writer.setText("Author", "John Smith"); ``` 之后筆者已經與格式相關的選項可以進行測試。 這個函數中引入了Qt 4.2中。 **See also** [QImageReader.supportsOption](qimagereader.html#supportsOption)()和[setFormat](qimagewriter.html#setFormat)( ) 。 ``` bool QImageWriter.write (self, QImage?image) ``` 寫入圖像_image_到指定的設備或文件名。成功時返回TRUE ,否則返回False 。如果操作失敗,您可以撥打[error](qimagewriter.html#error)()找到所發生的錯誤的類型,或者[errorString](qimagewriter.html#errorString)( )來獲得錯誤的可讀描述。 **See also** [canWrite](qimagewriter.html#canWrite)( )[error](qimagewriter.html#error)()和[errorString](qimagewriter.html#errorString)( ) 。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看