<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # QImage Class Reference ## [[QtGui](index.htm) module] QImage的類提供了與硬件無關的圖像表示,它允許直接訪問的像素數據,并可以作為一個繪圖設備。[More...](#details) 繼承[QPaintDevice](qpaintdevice.html)。 ### Types * `enum Format { Format_Invalid, Format_Mono, Format_MonoLSB, Format_Indexed8, ..., Format_ARGB4444_Premultiplied }` * `enum InvertMode { InvertRgb, InvertRgba }` ### Methods * `__init__ (self)` * `__init__ (self, QSize?size, Format?format)` * `__init__ (self, int?width, int?height, Format?format)` * `__init__ (self, str?data, int?width, int?height, Format?format)` * `__init__ (self, sip.voidptr?data, int?width, int?height, Format?format)` * `__init__ (self, str?data, int?width, int?height, int?bytesPerLine, Format?format)` * `__init__ (self, sip.voidptr?data, int?width, int?height, int?bytesPerLine, Format?format)` * `__init__ (self, list-of-str?xpm)` * `__init__ (self, QString?fileName, str?format?=?None)` * `__init__ (self, QImage)` * `__init__ (self, QVariant?variant)` * `bool allGray (self)` * `QImage alphaChannel (self)` * `int bitPlaneCount (self)` * `sip.voidptr bits (self)` * `int byteCount (self)` * `int bytesPerLine (self)` * `int cacheKey (self)` * `int color (self, int?i)` * `int colorCount (self)` * `list-of-int colorTable (self)` * `sip.voidptr constBits (self)` * `sip.voidptr constScanLine (self, int)` * `QImage convertToFormat (self, Format?format, Qt.ImageConversionFlags?flags?=?Qt.AutoColor)` * `QImage convertToFormat (self, Format?format, list-of-int?colorTable, Qt.ImageConversionFlags?flags?=?Qt.AutoColor)` * `QImage copy (self, QRect?rect?=?QRect())` * `QImage copy (self, int?x, int?y, int?w, int?h)` * `QImage createAlphaMask (self, Qt.ImageConversionFlags?flags?=?Qt.AutoColor)` * `QImage createHeuristicMask (self, bool?clipTight?=?True)` * `QImage createMaskFromColor (self, int?color, Qt.MaskMode?mode?=?Qt.MaskInColor)` * `int depth (self)` * `detach (self)` * `int devType (self)` * `int dotsPerMeterX (self)` * `int dotsPerMeterY (self)` * `fill (self, Qt.GlobalColor?color)` * `fill (self, QColor?color)` * `fill (self, int?pixel)` * `Format format (self)` * `bool hasAlphaChannel (self)` * `int height (self)` * `invertPixels (self, InvertMode?mode?=?QImage.InvertRgb)` * `bool isDetached (self)` * `bool isGrayscale (self)` * `bool isNull (self)` * `bool load (self, QIODevice?device, str?format)` * `bool load (self, QString?fileName, str?format?=?None)` * `bool loadFromData (self, str?data, str?format?=?None)` * `bool loadFromData (self, QByteArray?data, str?format?=?None)` * `int metric (self, QPaintDevice.PaintDeviceMetric?metric)` * `QImage mirrored (self, bool?horizontal?=?False, bool?vertical?=?True)` * `int numBytes (self)` * `int numColors (self)` * `QPoint offset (self)` * `QPaintEngine paintEngine (self)` * `int pixel (self, QPoint?pt)` * `int pixel (self, int?x, int?y)` * `int pixelIndex (self, QPoint?pt)` * `int pixelIndex (self, int?x, int?y)` * `QRect rect (self)` * `QImage rgbSwapped (self)` * `bool save (self, QString?fileName, str?format?=?None, int?quality?=?-1)` * `bool save (self, QIODevice?device, str?format?=?None, int?quality?=?-1)` * `QImage scaled (self, int?width, int?height, Qt.AspectRatioMode?aspectRatioMode?=?Qt.IgnoreAspectRatio, Qt.TransformationMode?transformMode?=?Qt.FastTransformation)` * `QImage scaled (self, QSize?size, Qt.AspectRatioMode?aspectRatioMode?=?Qt.IgnoreAspectRatio, Qt.TransformationMode?transformMode?=?Qt.FastTransformation)` * `QImage scaledToHeight (self, int?height, Qt.TransformationMode?mode?=?Qt.FastTransformation)` * `QImage scaledToWidth (self, int?width, Qt.TransformationMode?mode?=?Qt.FastTransformation)` * `sip.voidptr scanLine (self, int)` * `int serialNumber (self)` * `setAlphaChannel (self, QImage?alphaChannel)` * `setColor (self, int?i, int?c)` * `setColorCount (self, int)` * `setColorTable (self, list-of-int?colors)` * `setDotsPerMeterX (self, int)` * `setDotsPerMeterY (self, int)` * `setNumColors (self, int)` * `setOffset (self, QPoint)` * `setPixel (self, QPoint?pt, int?index_or_rgb)` * `setPixel (self, int?x, int?y, int?index_or_rgb)` * `setText (self, QString?key, QString?value)` * `QSize size (self)` * `swap (self, QImage?other)` * `QString text (self, QString?key?=?QString())` * `QStringList textKeys (self)` * `QImage transformed (self, QMatrix?matrix, Qt.TransformationMode?mode?=?Qt.FastTransformation)` * `QImage transformed (self, QTransform?matrix, Qt.TransformationMode?mode?=?Qt.FastTransformation)` * `bool valid (self, QPoint?pt)` * `bool valid (self, int?x, int?y)` * `int width (self)` ### Static Methods * `QImage fromData (str?data, str?format?=?None)` * `QImage fromData (QByteArray?data, str?format?=?None)` * `QMatrix trueMatrix (QMatrix, int?w, int?h)` * `QTransform trueMatrix (QTransform, int?w, int?h)` ### Special Methods * `bool __eq__ (self, QImage)` * `bool __ne__ (self, QImage)` * * * ## Detailed Description QImage的類提供了與硬件無關的圖像表示,它允許直接訪問的像素數據,并可以作為一個繪圖設備。 Qt提供了四個類用于處理圖像數據: QImage的,[QPixmap](qpixmap.html),[QBitmap](qbitmap.html)和[QPicture](qpicture.html)。 QImage的設計和優化的I / O和直接像素訪問和操作,而[QPixmap](qpixmap.html)設計并顯示在屏幕上的圖像進行了優化。[QBitmap](qbitmap.html)只有繼承一個方便的類[QPixmap](qpixmap.html),確保深度為1 。最后,該[QPicture](qpicture.html)類是一個繪圖設備,記錄和重放[QPainter](qpainter.html)的命令。 因為QImage的是[QPaintDevice](qpaintdevice.html)子類,[QPainter](qpainter.html)可用于直接繪制到圖像。當使用[QPainter](qpainter.html)在QImage的,這幅畫可以在另一個線程來執行比目前的GUI線程。 該QImage的類支持由所描述的幾種圖像格式[Format](qimage.html#Format-enum)枚舉。這些措施包括單色, 8位, 32位和alpha混合圖像這是適用于所有版本的Qt 4.x中的 QImage的規定的,可以被用來獲得各種有關圖像信息的功能的集合。也有幾個功能,使圖像的變換。 因為QImage的類使用QImage的對象可以被傳來傳去傳值[implicit data sharing](index.htm#implicit-data-sharing)。 QImage的對象也可以流并進行比較。 **Note:**如果你想加載QImage的對象在靜態編譯的Qt ,指的是[Plugin HowTo](index.htm#static-plugins)。 **Warning:**畫上的QImage與格式[QImage.Format_Indexed8](qimage.html#Format-enum)不被支持。 ### Reading and Writing Image Files 提供QImage的加載圖像文件的幾種方法:該文件可以構造QImage的對象時被加載,或使用[load](qimage.html#load)()或[loadFromData](qimage.html#loadFromData)( )函數以后。 QImage的還提供了靜態[fromData](qimage.html#fromData)()函數,從給定的數據構造一個QImage的。當加載一個圖像,文件名可以指在磁盤上的實際文件或應用的嵌入式資源之一。看[The Qt Resource System](index.htm)概述有關如何嵌入在應用程序的可執行映像和其他資源文件的詳細信息。 只需調用[save](qimage.html#save)( )函數來保存QImage的對象。 都可以通過支持的文件格式的完整列表[QImageReader.supportedImageFormats](qimagereader.html#supportedImageFormats)()和[QImageWriter.supportedImageFormats](qimagewriter.html#supportedImageFormats)()函數。新的文件格式可以添加插件。默認情況下, Qt支持以下格式: | Format | Description | Qt's support | | --- | --- | --- | | BMP | Windows Bitmap | Read/write | | GIF | Graphic Interchange Format (optional) | Read | | JPG | Joint Photographic Experts Group | Read/write | | JPEG | Joint Photographic Experts Group | Read/write | | PNG | Portable Network Graphics | Read/write | | PBM | Portable Bitmap | Read | | PGM | Portable Graymap | Read | | PPM | Portable Pixmap | Read/write | | TIFF | Tagged Image File Format | Read/write | | XBM | X11 Bitmap | Read/write | | XPM | X11 Pixmap | Read/write | ### Image Information QImage的規定的,可以被用來獲得各種有關圖像信息的功能的集合: | | Available Functions | | --- | --- | | Geometry | The [size](qimage.html#size)(), [width](qimage.html#width)(), [height](qimage.html#height)(), [dotsPerMeterX](qimage.html#dotsPerMeterX)(), and [dotsPerMeterY](qimage.html#dotsPerMeterY)() functions provide information about the image size and aspect ratio.該[rect](qimage.html#rect)( )函數返回圖像的外接矩形。該[valid](qimage.html#valid)( )函數告訴如果給定的對坐標是該矩形內。該[offset](qimage.html#offset)()函數返回由該圖像的目的是當使用位于相對于其他圖像,這些圖像也可以被操縱,以此作為偏移的像素的數量的[setOffset](qimage.html#setOffset)()函數。 | | Colors | The color of a pixel can be retrieved by passing its coordinates to the [pixel](qimage.html#pixel)() function. The [pixel](qimage.html#pixel)() function returns the color as a [QRgb](qcolor.html#QRgb-typedef) value indepedent of the image's format.在單色的情況下和8位的圖像,該[colorCount](qimage.html#colorCount)()和[colorTable](qimage.html#colorTable)()函數提供了有關用于存儲圖像數據的顏色成分的信息:該[colorTable](qimage.html#colorTable)( )函數返回圖像的整個顏色表。為了得到一個單一的項目,請使用[pixelIndex](qimage.html#pixelIndex)( )函數來檢索一個給定的對坐標的像素索引,然后使用[color](qimage.html#color)( )函數來檢索的顏色。請注意,如果您手動創建一個8位圖像,你必須設置在圖像上有效的顏色表也是如此。該[hasAlphaChannel](qimage.html#hasAlphaChannel)( )函數告訴如果圖像的格式,尊重alpha通道,還是不行。該[allGray](qimage.html#allGray)()和[isGrayscale](qimage.html#isGrayscale)( )函數告訴了圖像的顏色是否是灰色的形形色色。另見[Pixel Manipulation](#pixel-manipulation)和[Image Transformations](#image-transformations)部分。 | | Text | The [text](qimage.html#text)() function returns the image text associated with the given text key. An image's text keys can be retrieved using the [textKeys](qimage.html#textKeys)() function. Use the [setText](qimage.html#setText)() function to alter an image's text. | | Low-level information | The [depth](qimage.html#depth)() function returns the depth of the image. The supported depths are 1 (monochrome), 8, 16, 24 and 32 bits. The [bitPlaneCount](qimage.html#bitPlaneCount)() function tells how many of those bits that are used. For more information see the [Image Formats](#image-formats) section.該[format](qimage.html#format)( )[bytesPerLine](qimage.html#bytesPerLine)()和[byteCount](qimage.html#byteCount)()函數提供關于存儲的圖像中的數據的低級別信息。該[cacheKey](qimage.html#cacheKey)( )函數返回一個數字,它唯一標識此QImage的對象的內容。 | ### Pixel Manipulation 用于處理圖像的像素的功能取決于圖像格式。其原因是單色和8位圖像是基于索引的,并使用一個顏色查找表,而32位圖像存儲ARGB值直接。有關圖像格式的詳細信息,請參閱[Image Formats](#image-formats)一節。 萬一一個32位的圖像,本[setPixel](qimage.html#setPixel)()函數可以被用來改變該像素的顏色在指定的ARGB四聯的給定坐標的任何其他顏色。為了讓合適的[QRgb](qcolor.html#QRgb-typedef)值,使用[qRgb](index.htm#qRgb)( ) (添加一個默認的alpha分量給定的RGB值,即創建一個不透明的顏色)或[qRgba](index.htm#qRgba)()函數。例如: | 32-bit | | --- | | ![](https://img.kancloud.cn/e8/d6/e8d6ea5a24256e34d34b94c500820484_284x284.png) | ``` QImage image(3, 3, QImage.Format_RGB32); [QRgb](qcolor.html#QRgb-typedef) value; value = qRgb(189, 149, 39); // 0xffbd9527 image.setPixel(1, 1, value); value = qRgb(122, 163, 39); // 0xff7aa327 image.setPixel(0, 1, value); image.setPixel(1, 0, value); value = qRgb(237, 187, 51); // 0xffedba31 image.setPixel(2, 1, value); ``` | 在殼體的8位和monchrome圖像中,像素值是只從圖像的顏色表的索引。所以,[setPixel](qimage.html#setPixel)()函數僅可用于改變像素的顏色在給定的坐標以一個預定義的色彩從該圖像的顏色表,即它只能改變像素的索引值。要更改或添加顏色到圖像的顏色表,使用[setColor](qimage.html#setColor)()函數。 在顏色表中的條目是一個ARGB四胞胎編碼為[QRgb](qcolor.html#QRgb-typedef)值。使用[qRgb](index.htm#qRgb)()和[qRgba](index.htm#qRgba)( )函數來作出適當的[QRgb](qcolor.html#QRgb-typedef)值與使用[setColor](qimage.html#setColor)()函數。例如: | 8-bit | | --- | | ![](https://img.kancloud.cn/2f/3f/2f3f5ea390d90a2878f512c8d7e690b6_414x284.png) | ``` QImage image(3, 3, QImage.Format_Indexed8); [QRgb](qcolor.html#QRgb-typedef) value; value = qRgb(122, 163, 39); // 0xff7aa327 image.setColor(0, value); value = qRgb(237, 187, 51); // 0xffedba31 image.setColor(1, value); value = qRgb(189, 149, 39); // 0xffbd9527 image.setColor(2, value); image.setPixel(0, 1, 0); image.setPixel(1, 0, 0); image.setPixel(1, 1, 2); image.setPixel(2, 1, 1); ``` | QImage的還提供了[scanLine](qimage.html#scanLine)( )函數返回一個指向像素數據在給定索引掃描線,以及[bits](qimage.html#bits)( )函數返回一個指向第一個像素的數據(這相當于`scanLine(0)`) 。 ### Image Formats 存儲在一個QImage的每個像素由一個整數表示。視格式的整數的大小而有所不同。 QImage的支持由所描述的幾種圖像格式[Format](qimage.html#Format-enum)枚舉。 單色圖像使用的是1位索引到顏色表最多兩種顏色存儲。有兩種不同類型的黑白圖像:大端(高位在前)和little endian(低位在前)位順序。 8位的圖像是使用8位的索引到一個顏色表中存儲的,即它們具有每像素一個字節。該顏色表是一個[QVector](index.htm)\u003c[QRgb](qcolor.html#QRgb-typedef)\u003e和[QRgb](qcolor.html#QRgb-typedef)的typedef相當于包含的格式0xAARRGGBB一個ARGB四胞胎一個unsigned int 。 32位圖像沒有顏色表,而是每個像素包含一個[QRgb](qcolor.html#QRgb-typedef)值。有三種不同類型的32位圖像分別存儲的RGB (即0xffRRGGBB ) , ARGB和預乘的ARGB值。在預乘格式的紅色,綠色和藍色通道是由alpha分量除以255乘以。 的圖像的格式可以用要檢索的[format](qimage.html#format)()函數。使用[convertToFormat](qimage.html#convertToFormat)()函數將圖像轉換成另一種格式。該[allGray](qimage.html#allGray)()和[isGrayscale](qimage.html#isGrayscale)()函數判斷是否彩色圖像可以安全地被轉換為灰度圖像。 ### Image Transformations QImage的支持許多函數,用于創建一個新的圖像,它是原始的轉換后的版本:該[createAlphaMask](qimage.html#createAlphaMask)( )函數建立和從這個圖片的alpha緩沖區返回一個1 - BPP掩碼和[createHeuristicMask](qimage.html#createHeuristicMask)( )函數創建并返回一個1 - BPP啟發式掩碼這一形象。后者的功能是通過從一個角中選擇一種顏色,然后小打小鬧該顏色的起始像素的所有邊。 該[mirrored](qimage.html#mirrored)()函數返回的圖像的反射鏡在所需方向上的[scaled](qimage.html#scaled)()返回的圖像縮放到所要求的措施,一個矩形的副本,并且該[rgbSwapped](qimage.html#rgbSwapped)( )函數構造一個BGR圖像從RGB圖像。 該[scaledToWidth](qimage.html#scaledToWidth)()和[scaledToHeight](qimage.html#scaledToHeight)( )函數返回圖像的縮放復印。 該[transformed](qimage.html#transformed)( )函數返回的轉化與給定的變換矩陣與變換模式的圖像的副本:在內部,該變換矩陣進行調整,以補償不需要翻譯,即[transformed](qimage.html#transformed)( )返回一個包含原始圖像的所有變換的點的最小圖像。靜[trueMatrix](qimage.html#trueMatrix)()函數返回用于變換圖像的實際矩陣。 也有用于改變就地圖像的屬性功能: | Function | Description | | --- | --- | | [setDotsPerMeterX](qimage.html#setDotsPerMeterX)() | Defines the aspect ratio by setting the number of pixels that fit horizontally in a physical meter. | | [setDotsPerMeterY](qimage.html#setDotsPerMeterY)() | Defines the aspect ratio by setting the number of pixels that fit vertically in a physical meter. | | [fill](qimage.html#fill)() | Fills the entire image with the given pixel value. | | [invertPixels](qimage.html#invertPixels)() | Inverts all pixel values in the image using the given [InvertMode](qimage.html#InvertMode-enum) value. | | [setColorTable](qimage.html#setColorTable)() | Sets the color table used to translate color indexes. Only monochrome and 8-bit formats. | | [setColorCount](qimage.html#setColorCount)() | Resizes the color table. Only monochrome and 8-bit formats. | ### Legal Information 對于平滑縮放,[transformed](qimage.html#transformed)( )函數使用的代碼基礎上由Daniel M. Duley平滑縮放算法。 版權所有(C ) 2004,2005丹尼爾米Duley 再分配和在源代碼和二進制形式的使用,無論修改與否,都允許下列條件: 1 。源代碼的再分發必須保留上述版權聲明,此條件列表和以下免責聲明。 2 。以二進制形式再分發必須復制上述版權聲明,此條件列表和文檔和/或隨分發提供的其他材料中的下列免責聲明。 本軟件是由作者``原樣''任何明示或暗示的擔保,包括但不限于適銷性和適用性的暗示擔保適用于某一特定用途的保證。在任何情況下,作者均不對任何直接的,間接的,附帶的,特殊的,懲罰性的或后果性的損害(包括但不限于購買替代商品或服務,使用損失,數據丟失或利潤損失或業務中斷)而引起的任何責任理論,無論是在合同,嚴格賠償責任或民事侵權行為(包括疏忽或其它)以任何方式產生出這種軟件的使用,即使已被告知發生此類損害的可能性。 * * * ## Type Documentation ``` QImage.Format ``` 下面的圖像格式,可在Qt的。值大于QImage.Format_RGB16分別加入Qt的4.4 。請參閱下表后的注意事項。 | Constant | Value | Description | | --- | --- | --- | | `QImage.Format_Invalid` | `0` | 該圖像是無效的。 | | `QImage.Format_Mono` | `1` | 該圖像是使用每像素1位的存儲。字節首先擠滿了最顯著的位(MSB ) 。 | | `QImage.Format_MonoLSB` | `2` | 該圖像是使用每像素1位的存儲。字節首先擠滿了少顯著位(LSB ) 。 | | `QImage.Format_Indexed8` | `3` | 該圖像是用8位的索引為一個顏色表存儲。 | | `QImage.Format_RGB32` | `4` | 該圖像是使用一個32位的RGB格式( 0xffRRGGBB )存儲。 | | `QImage.Format_ARGB32` | `5` | 該圖像是使用一個32位ARGB格式( 0xAARRGGBB )存儲。 | | `QImage.Format_ARGB32_Premultiplied` | `6` | 該圖像是使用預乘32位ARGB格式( 0xAARRGGBB )存儲,即紅色,綠色和藍色通道是由alpha分量除以255乘以。 (如果RR,GG或BB有更高的價值比alpha通道,結果是不確定的。 )某些操作(如使用alpha混合圖像組合物)使用速度更快左乘ARGB32比普通ARGB32 。 | | `QImage.Format_RGB16` | `7` | 該圖像是使用一個16位的RGB格式( 5-6-5 )存儲。 | | `QImage.Format_ARGB8565_Premultiplied` | `8` | 該圖像是使用預乘24位ARGB格式( 8-5-6-5 )存儲。 | | `QImage.Format_RGB666` | `9` | 該圖像是用一個24位的RGB格式( 6-6-6 )存儲。未使用的最顯著的位始終為零。 | | `QImage.Format_ARGB6666_Premultiplied` | `10` | 該圖像是使用預乘24位ARGB格式( 6-6-6-6 )存儲。 | | `QImage.Format_RGB555` | `11` | 該圖像是使用一個16位的RGB格式( 5-5-5 )存儲。未使用的最顯著位始終為零。 | | `QImage.Format_ARGB8555_Premultiplied` | `12` | 該圖像是使用預乘24位ARGB格式( 8-5-5-5 )存儲。 | | `QImage.Format_RGB888` | `13` | 該圖像是用一個24位的RGB格式( 8-8-8 )存儲。 | | `QImage.Format_RGB444` | `14` | 該圖像是使用一個16位的RGB格式( 4-4-4 )存儲。未使用的位始終為零。 | | `QImage.Format_ARGB4444_Premultiplied` | `15` | 該圖像是使用預乘16位ARGB格式( 4-4-4-4 )存儲。 | **Note:**拉絲成[QImage](qimage.html)與QImage.Format_Indexed8不支持。 **Note:**不要渲染成ARGB32使用的圖像[QPainter](qpainter.html)。使用QImage.Format_ARGB32_Premultiplied是顯著更快。 **See also** [format](qimage.html#format)()和[convertToFormat](qimage.html#convertToFormat)( ) 。 ``` QImage.InvertMode ``` 該枚舉類型用于描述如何像素值應在倒[invertPixels](qimage.html#invertPixels)()函數。 | Constant | Value | Description | | --- | --- | --- | | `QImage.InvertRgb` | `0` | 僅反轉的RGB值,并保留alpha通道不變。 | | `QImage.InvertRgba` | `1` | 反轉所有通道,包括Alpha通道。 | **See also** [invertPixels](qimage.html#invertPixels)( ) 。 * * * ## Method Documentation ``` QImage.__init__ (self) ``` 構造一個空圖像。 **See also** [isNull](qimage.html#isNull)( ) 。 ``` QImage.__init__ (self, QSize?size, Format?format) ``` 構造一個圖像與給定的_size_和_format_。 A [null](qimage.html#isNull)如果內存無法分配圖像返回。 **Warning:**這將創建一個[QImage](qimage.html)與未初始化的數據。通話[fill](qimage.html#fill)( )與繪制到它之前,以填補一個合適的像素值的圖像[QPainter](qpainter.html)。 ``` QImage.__init__ (self, int?width, int?height, Format?format) ``` 構造一個圖像與給定的_width_,_height_和_format_。 A [null](qimage.html#isNull)如果內存無法分配圖像將被退回。 **Warning:**這將創建一個[QImage](qimage.html)與未初始化的數據。通話[fill](qimage.html#fill)( )與繪制到它之前,以填補一個合適的像素值的圖像[QPainter](qpainter.html)。 ``` QImage.__init__ (self, str?data, int?width, int?height, Format?format) ``` 構造一個圖像與給定的_width_,_height_和_format_,使用現有的內存緩沖區,_data_。該_width_和_height_必須以像素為單位來指定,_data_必須是32位對齊的,并且在圖像數據的每一個的掃描線也必須是32位對齊的。 該緩沖區必須保持有效的整個的生命[QImage](qimage.html)。圖像不會刪除緩沖區破壞。 If _format_是一種索引顏色格式,圖像顏色表開始是空的,必須充分擴展了[setColorCount](qimage.html#setColorCount)()或[setColorTable](qimage.html#setColorTable)()的圖像被使用之前。 ``` QImage.__init__ (self, sip.voidptr?data, int?width, int?height, Format?format) ``` 構造一個圖像與給定的_width_,_height_和_format_中,使用現有的只讀存儲器緩沖器,_data_。該_width_和_height_必須以像素為單位來指定,_data_必須是32位對齊的,并且在圖像數據的每一個的掃描線也必須是32位對齊的。 該緩沖區必須保持有效的整個的生命[QImage](qimage.html)而那些沒有被修改或以其他方式脫離了原來的緩沖區中的所有副本。圖像不會刪除緩沖區破壞。 If _format_是一種索引顏色格式,圖像顏色表開始是空的,必須充分擴展了[setColorCount](qimage.html#setColorCount)()或[setColorTable](qimage.html#setColorTable)()的圖像被使用之前。 不同于類似[QImage](qimage.html)構造函數接受一個非const數據緩沖區,該版本將永遠不會改變緩沖區的內容。例如,調用[QImage.bits](qimage.html#bits)( )將返回圖像的深層副本,而不是緩沖區傳遞給構造函數。這使得構建的效率[QImage](qimage.html)從原始數據,而不對原始數據被改變的可能性。 ``` QImage.__init__ (self, str?data, int?width, int?height, int?bytesPerLine, Format?format) ``` 構造一個圖像與給定的_width_,_height_和_format_,使用現有的內存緩沖區,_data_。該_width_和_height_必須以像素為單位來指定。_bytesPerLine_指定每行(步幅)的字節數。 該緩沖區必須保持有效的整個的生命[QImage](qimage.html)。圖像不會刪除緩沖區破壞。 If _format_是一種索引顏色格式,圖像顏色表開始是空的,必須充分擴展了[setColorCount](qimage.html#setColorCount)()或[setColorTable](qimage.html#setColorTable)()的圖像被使用之前。 ``` QImage.__init__ (self, sip.voidptr?data, int?width, int?height, int?bytesPerLine, Format?format) ``` 構造一個圖像與給定的_width_,_height_和_format_,使用現有的內存緩沖區,_data_。該_width_和_height_必須以像素為單位來指定。_bytesPerLine_指定每行(步幅)的字節數。 該緩沖區必須保持有效的整個的生命[QImage](qimage.html)。圖像不會刪除緩沖區破壞。 If _format_是一種索引顏色格式,圖像顏色表開始是空的,必須充分擴展了[setColorCount](qimage.html#setColorCount)()或[setColorTable](qimage.html#setColorTable)()的圖像被使用之前。 不同于類似[QImage](qimage.html)構造函數接受一個非const數據緩沖區,該版本將永遠不會改變緩沖區的內容。例如,調用[QImage.bits](qimage.html#bits)( )將返回圖像的深層副本,而不是緩沖區傳遞給構造函數。這使得構建的效率[QImage](qimage.html)從原始數據,而不對原始數據被改變的可能性。 ``` QImage.__init__ (self, list-of-str?xpm) ``` 構造一個圖像從給定的_xpm_圖像。 確保圖像是一個有效的XPM圖像。錯誤被忽略。 請注意,它可能通過使用一個不同尋常的聲明擠壓XPM變量一點點: ``` static const char * const start_xpm[] = { "16 15 8 1", "a c #cec6bd", .... ``` 額外的`const`使得整個定義為只讀,這會更有效(例如,當代碼是在一個共享庫),并能夠存儲在ROM中的應用程序。 ``` QImage.__init__ (self, QString?fileName, str?format?=?None) ``` 構造一個圖像,并嘗試從該文件與給定的加載圖像_fileName_。 加載器會嘗試使用指定的讀取圖像_format_。如果_format_未指定(這是默認值) ,加載器探測文件的標題來猜測文件格式。 如果圖像的裝載失敗,這個對象是一個空的圖像。 文件名可以是指在磁盤上的實際文件或應用的嵌入式資源之一。請參閱[Resource System](index.htm)概述有關如何嵌入在應用程序的可執行映像和其他資源文件的詳細信息。 **See also** [isNull](qimage.html#isNull)()和[Reading and Writing Image Files](qimage.html#reading-and-writing-image-files)。 ``` QImage.__init__ (self, QImage) ``` 構造一個圖像,并嘗試從該文件與給定的加載圖像_fileName_。 加載器會嘗試使用指定的讀取圖像_format_。如果_format_未指定(這是默認值) ,加載器探測文件的標題來猜測文件格式。 如果圖像的裝載失敗,這個對象是一個空的圖像。 文件名可以是指在磁盤上的實際文件或應用的嵌入式資源之一。請參閱[Resource System](index.htm)概述有關如何嵌入在應用程序的可執行映像和其他資源文件的詳細信息。 您可以通過定義禁用此構造函數`QT_NO_CAST_FROM_ASCII`當您編譯您的應用程序。這可能是有用的,例如,如果你想確保所有用戶可見的字符串經過[QObject.tr](qobject.html#tr)( ) 。 **See also** [QString.fromAscii](qstring.html#fromAscii)( )[isNull](qimage.html#isNull)()和[Reading and Writing Image Files](qimage.html#reading-and-writing-image-files)。 ``` QImage.__init__ (self, QVariant?variant) ``` 構造給定的淺表副本_image_。 如需淺副本的詳細信息,請參閱[Implicit Data Sharing](index.htm#implicit-data-sharing)文檔。 **See also** [copy](qimage.html#copy)( ) 。 ``` bool QImage.allGray (self) ``` 返回True如果圖像中所有的顏色都是灰色的(也就是他們的紅色,綠色和藍色成分相同)的陰影,否則為False 。 注意,這個函數是沒有顏色表的圖像緩慢。 **See also** [isGrayscale](qimage.html#isGrayscale)( ) 。 ``` QImage QImage.alphaChannel (self) ``` [ ``` int QImage.bitPlaneCount (self) ``` 返回的圖像中的位平面的數目。 位平面的數目為顏色和透明度信息對每個像素的比特數。這是從深度(即小于)時,圖像格式包含未用的比特不同。 此功能被引入Qt的4.7 。 ](qimage.html) [**See also**](qimage.html) [depth](qimage.html#depth)( )[format](qimage.html#format)()和[Image Formats](qimage.html#image-formats)。 ``` sip.voidptr QImage.bits (self) ``` 將指針返回到所述第一像素數據。這相當于掃描線(0)。 需要注意的是[QImage](qimage.html) uses [implicit data sharing](index.htm#implicit-data-sharing)。這個函數執行的共享像素數據的深層副本,從而確保這[QImage](qimage.html)可使用現行的返回值是唯一一個。 **See also** [scanLine](qimage.html#scanLine)( )[byteCount](qimage.html#byteCount)()和[constBits](qimage.html#constBits)( ) 。 ``` int QImage.byteCount (self) ``` 返回由圖像數據所佔用的字節數。 此功能被引入Qt的4.6 。 **See also** [bytesPerLine](qimage.html#bytesPerLine)( )[bits](qimage.html#bits)()和[Image Information](qimage.html#image-information)。 ``` int QImage.bytesPerLine (self) ``` 返回每幅圖像掃描線的字節數。 這等效于[byteCount](qimage.html#byteCount)()/[height](qimage.html#height)( ) 。 **See also** [scanLine](qimage.html#scanLine)( ) 。 ``` int QImage.cacheKey (self) ``` 返回一個數字,用于標識此內容[QImage](qimage.html)對象。不同[QImage](qimage.html)對象只能具有相同的密鑰,如果它們指的是相同的內容。 該鍵將改變當圖像被改變。 ``` int QImage.color (self, int?i) ``` 在索引返回的顏色的顏色表_i_。第一種顏色的索引為0 。 圖像中的顏色表中的顏色指定為ARGB四胞胎([QRgb](qcolor.html#QRgb-typedef)) 。使用[qAlpha](index.htm#qAlpha)( )[qRed](index.htm#qRed)( )[qGreen](index.htm#qGreen)()和[qBlue](index.htm#qBlue)( )函數來獲取顏色值的組件。 **See also** [setColor](qimage.html#setColor)( )[pixelIndex](qimage.html#pixelIndex)()和[Pixel Manipulation](qimage.html#pixel-manipulation)。 ``` int QImage.colorCount (self) ``` 返回顏色表的圖像的大小。 請注意, colorCount ( )返回0表示32位色的圖像,因為這些圖像不使用顏色表,而是編碼的像素值作為ARGB四胞胎。 此功能被引入Qt的4.6 。 **See also** [setColorCount](qimage.html#setColorCount)()和[Image Information](qimage.html#image-information)。 ``` list-of-int QImage.colorTable (self) ``` 返回包含在圖像的顏色表中的顏色列表,或者一個空列表,如果圖像沒有顏色表 **See also** [setColorTable](qimage.html#setColorTable)( )[colorCount](qimage.html#colorCount)()和[color](qimage.html#color)( ) 。 ``` sip.voidptr QImage.constBits (self) ``` 將指針返回到所述第一像素數據。 需要注意的是[QImage](qimage.html) uses [implicit data sharing](index.htm#implicit-data-sharing),但這個函數_not_執行共享像素數據的深層副本,因為返回的數據是常量。 此功能被引入Qt的4.7 。 **See also** [bits](qimage.html#bits)()和[constScanLine](qimage.html#constScanLine)( ) 。 ``` sip.voidptr QImage.constScanLine (self, int) ``` 返回一個指針,指向像素數據與索引掃描線_i_。第一個掃描行的索引為0 。 該掃描線數據是對齊的32位邊界。 需要注意的是[QImage](qimage.html) uses [implicit data sharing](index.htm#implicit-data-sharing),但這個函數_not_執行共享像素數據的深層副本,因為返回的數據是常量。 此功能被引入Qt的4.7 。 **See also** [scanLine](qimage.html#scanLine)()和[constBits](qimage.html#constBits)( ) 。 ``` QImage QImage.convertToFormat (self, Format?format, Qt.ImageConversionFlags?flags?=?Qt.AutoColor) ``` [ 返回圖像的一個副本在給定的_format_。 指定的圖像轉換_flags_控制如何在轉換過程中的圖像數據被處理。 ](qimage.html) [**See also**](qimage.html) [Image Format](qimage.html#image-formats)。 ``` QImage QImage.convertToFormat (self, Format?format, list-of-int?colorTable, Qt.ImageConversionFlags?flags?=?Qt.AutoColor) ``` [ 這是一個重載函數。 返回的圖像的副本轉換為給定_format_使用指定的_colorTable_。 從32位到8位索引轉換是一個緩慢的操作,將使用一個簡單的最接近的顏色的方法,無抖動。 ](qimage.html) ``` QImage QImage.copy (self, QRect?rect?=?QRect()) ``` [ 返回圖像的子區域作為一個新的形象。 返回的圖像從位置復制(_rectangle_, X( ) ,_rectangle_, Y( ) )在這個形象,并總是具有給定的尺寸_rectangle_。 ](qimage.html) [在此以外的圖像區域,像素被設置為0。對于32位RGB圖像,這意味著黑,為32位ARGB圖像,這意味著透明的黑色;為8位圖像,這意味著索引為0的顏色表,可以是任何顏色, 1位圖像中,這意味著](qimage.html)[Qt.color0](qt.html#GlobalColor-enum)。 如果給定的_rectangle_是一個空矩形整個圖像被復制。 **See also** [QImage](qimage.html#QImage)( ) 。 ``` QImage QImage.copy (self, int?x, int?y, int?w, int?h) ``` [](qimage.html) ``` QImage QImage.createAlphaMask (self, Qt.ImageConversionFlags?flags?=?Qt.AutoColor) ``` [](qimage.html) [構建并從該圖像的alpha緩沖區返回1 BPP掩碼。返回一個空圖像,如果圖像的格式是](qimage.html)[QImage.Format_RGB32](qimage.html#Format-enum)。 該_flags_參數是的一個按位或[Qt.ImageConversionFlags](qt.html#ImageConversionFlag-enum)和控制轉換過程。路過0標志設置所有默認選項。 返回的圖像有小端位順序(即圖像的格式是[QImage.Format_MonoLSB](qimage.html#Format-enum)) ,你可以轉換為大端([QImage.Format_Mono](qimage.html#Format-enum))使用[convertToFormat](qimage.html#convertToFormat)()函數。 **See also** [createHeuristicMask](qimage.html#createHeuristicMask)()和[Image Transformations](qimage.html#image-transformations)。 ``` QImage QImage.createHeuristicMask (self, bool?clipTight?=?True) ``` [ 創建并返回一個1 - BPP啟發式掩碼這一形象。 該功能的工作原理是從一個角選擇一種顏色,然后小打小鬧的顏色開始的像素,所有的邊緣。四角投票的顏色是被屏蔽了。的情況下的拉伸(這通常意味著這個函數是不適用的圖像) ,其結果是任意的。 ](qimage.html) [返回的圖像有小端位順序(即圖像的格式是](qimage.html)[QImage.Format_MonoLSB](qimage.html#Format-enum)) ,你可以轉換為大端([QImage.Format_Mono](qimage.html#Format-enum))使用[convertToFormat](qimage.html#convertToFormat)()函數。 If _clipTight_為True(默認值)的面具只是大到足以復蓋的像素,否則,面膜比數據像素。 注意,這個函數會忽略的alpha緩沖區。 **See also** [createAlphaMask](qimage.html#createAlphaMask)()和[Image Transformations](qimage.html#image-transformations)。 ``` QImage QImage.createMaskFromColor (self, int?color, Qt.MaskMode?mode?=?Qt.MaskInColor) ``` [ 創建并返回的基礎上,給出了這一形象口罩_color_值。如果_mode_是MaskInColor (默認值) ,所有像素匹配_color_將不透明像素的掩模。如果_mode_是MaskOutColor ,匹配給定顏色的所有像素將是透明的。 ](qimage.html) [**See also**](qimage.html) [createAlphaMask](qimage.html#createAlphaMask)()和[createHeuristicMask](qimage.html#createHeuristicMask)( ) 。 ``` int QImage.depth (self) ``` 返回圖像的深度。 圖像深度是用來存儲一個像素的比特數,也稱為每像素(bpp )位。 支持的深度是1 , 8 , 16 , 24和32 。 **See also** [bitPlaneCount](qimage.html#bitPlaneCount)( )[convertToFormat](qimage.html#convertToFormat)( )[Image Formats](qimage.html#image-formats)和[Image Information](qimage.html#image-information)。 ``` QImage.detach (self) ``` ``` int QImage.devType (self) ``` ``` int QImage.dotsPerMeterX (self) ``` 返回適合水平地在一個物理米的像素的數目。再加上[dotsPerMeterY](qimage.html#dotsPerMeterY)(),這個數定義期望的規模和圖像的縱橫比。 **See also** [setDotsPerMeterX](qimage.html#setDotsPerMeterX)()和[Image Information](qimage.html#image-information)。 ``` int QImage.dotsPerMeterY (self) ``` 返回適合垂直于一個物理米的像素的數目。再加上[dotsPerMeterX](qimage.html#dotsPerMeterX)(),這個數定義期望的規模和圖像的縱橫比。 **See also** [setDotsPerMeterY](qimage.html#setDotsPerMeterY)()和[Image Information](qimage.html#image-information)。 ``` QImage.fill (self, Qt.GlobalColor?color) ``` 填充整個圖像具有給定_pixelValue_。 如果這個圖像的深度為1,只有最低位被使用。如果你說填( 0 ) ,填充( 2 )等,圖像充滿了0。如果你說的填寫( 1 ) ,填充( 3 )等,圖像充滿了1秒。如果深度是8 ,最低的8位被使用,如果深度為16的最低16比特的使用。 注意:[QImage.pixel](qimage.html#pixel)( )返回像素的顏色,而在給定坐標[QColor.pixel](index.htm#pixel)( )返回底層窗口系統(本質上是一個索引值)的像素值,因此通常你會希望使用[QImage.pixel](qimage.html#pixel)()使用從現有的圖像的顏色或[QColor.rgb](qcolor.html#rgb)()使用特定的顏色。 **See also** [depth](qimage.html#depth)()和[Image Transformations](qimage.html#image-transformations)。 ``` QImage.fill (self, QColor?color) ``` 這是一個重載函數。 填充圖像與給定的_color_,描述為一個標準的全球色彩。 此功能被引入Qt的4.8 。 ``` QImage.fill (self, int?pixel) ``` 這是一個重載函數。 填充整個圖像具有給定_color_。 如果圖像的深度為1 ,則圖像將充滿1如果_color_等于[Qt.color1](qt.html#GlobalColor-enum)它否則將被填0。 如果圖像的深度是8 ,該圖像將被填充的索引對應的_color_在顏色表中如果存在的話,它會以其他方式填0。 此功能被引入Qt的4.8 。 ``` Format QImage.format (self) ``` [ 返回的圖像的格式。 ](qimage.html#Format-enum) [**See also**](qimage.html#Format-enum) [Image Formats](qimage.html#image-formats)。 ``` QImage QImage.fromData (str?data, str?format?=?None) ``` [](qimage.html) [構造一個](qimage.html)[QImage](qimage.html)從第一_size_給定的二進制字節_data_。加載器會嘗試使用指定的讀取圖像_format_。如果_format_未指定(這是默認值) ,加載器探測文件的標題來猜測文件格式。二進制_data_。裝載機嘗試讀取圖像,或者使用可選的圖像_format_指定或通過確定從數據的圖像格式。 If _format_未指定(這是默認值) ,加載器探針頭的文件,以確定該文件的格式。如果_format_被指定,它必須是通過返回的值之一[QImageReader.supportedImageFormats](qimagereader.html#supportedImageFormats)( ) 。 如果圖像的裝載失敗,返回的圖像將是一個空的圖像。 **See also** [load](qimage.html#load)( )[save](qimage.html#save)()和[Reading and Writing Image Files](qimage.html#reading-and-writing-image-files)。 ``` QImage QImage.fromData (QByteArray?data, str?format?=?None) ``` [ 這是一個重載函數。 ](qimage.html) [加載一個圖像從給定的](qimage.html)[QByteArray](qbytearray.html) _data_。 ``` bool QImage.hasAlphaChannel (self) ``` 返回True如果圖像有一個尊重的alpha通道的格式,否則返回False 。 **See also** [Image Information](qimage.html#image-information)。 ``` int QImage.height (self) ``` 返回圖像的高度。 **See also** [Image Information](qimage.html#image-information)。 ``` QImage.invertPixels (self, InvertMode?mode?=?QImage.InvertRgb) ``` 反轉圖像中的所有像素值。 給定的倒置_mode_只有一個意義時,圖像的深度為32。默認_mode_ is [InvertRgb](qimage.html#InvertMode-enum),這讓alpha通道不變。如果_mode_ is [InvertRgba](qimage.html#InvertMode-enum)中,α位也反轉。 反相一個8位圖像是指采用顯色指數,以取代所有像素_i_使用顯色指數255減去像素_i_。同樣是一個1位的圖像的情況。注意,顏色表是_not_改變。 **See also** [Image Transformations](qimage.html#image-transformations)。 ``` bool QImage.isDetached (self) ``` ``` bool QImage.isGrayscale (self) ``` 對于32位圖像,這個功能相當于[allGray](qimage.html#allGray)( ) 。 對于8位色的圖像,這個功能如果顏色( i)為返回True[QRgb](qcolor.html#QRgb-typedef)( I, I,I )的顏色表的所有索引,否則返回False 。 **See also** [allGray](qimage.html#allGray)()和[Image Formats](qimage.html#image-formats)。 ``` bool QImage.isNull (self) ``` 返回True ,如果它是一個空圖像,否則返回False 。 一個空的圖像具有設置為零的所有參數,沒有分配的數據。 ``` bool QImage.load (self, QIODevice?device, str?format) ``` 加載一個圖像從文件中給定的_fileName_。返回True如果成功加載圖像,否則返回False 。 加載器會嘗試使用指定的讀取圖像_format_,例如, PNG或JPG格式。如果_format_未指定(這是默認值) ,加載器探測文件的標題來猜測文件格式。 文件名可以是指在磁盤上的實際文件或應用的嵌入式資源之一。請參閱[Resource System](index.htm)概述有關如何嵌入在應用程序的可執行映像和其他資源文件的詳細信息。 **See also** [Reading and Writing Image Files](qimage.html#reading-and-writing-image-files)。 ``` bool QImage.load (self, QString?fileName, str?format?=?None) ``` 這是一個重載函數。 該函數讀取[QImage](qimage.html)從給定的_device_。這可以,例如,可以用來直接將圖像加載到一個[QByteArray](qbytearray.html)。 ``` bool QImage.loadFromData (self, str?data, str?format?=?None) ``` 加載一個圖像從第一_len_給定的二進制字節_data_。返回True如果成功加載圖像,否則返回False 。 加載器會嘗試使用指定的讀取圖像_format_,例如, PNG或JPG格式。如果_format_未指定(這是默認值) ,加載器探測文件的標題來猜測文件格式。 **See also** [Reading and Writing Image Files](qimage.html#reading-and-writing-image-files)。 ``` bool QImage.loadFromData (self, QByteArray?data, str?format?=?None) ``` 這是一個重載函數。 加載一個圖像從給定的[QByteArray](qbytearray.html) _data_。 ``` int QImage.metric (self, QPaintDevice.PaintDeviceMetric?metric) ``` ``` QImage QImage.mirrored (self, bool?horizontal?=?False, bool?vertical?=?True) ``` [ 返回圖像的鏡像,鏡像中的水平和/或垂直方向取決于是否_horizontal_和_vertical_被設置為True或False 。 請注意,原始圖像沒有改變。 ](qimage.html) [**See also**](qimage.html) [Image Transformations](qimage.html#image-transformations)。 ``` int QImage.numBytes (self) ``` ``` int QImage.numColors (self) ``` ``` QPoint QImage.offset (self) ``` [ 返回由該圖像的目的是當定位相對于其它圖像由被抵消的像素的數目。 ](qpoint.html) [**See also**](qpoint.html) [setOffset](qimage.html#setOffset)() and [Image Information](qimage.html#image-information). ``` QPaintEngine QImage.paintEngine (self) ``` [ ``` int QImage.pixel (self, QPoint?pt) ``` 返回該像素的顏色在給定的_position_。 如果_position_是無效的,結果是不確定的。 **Warning:**此功能是昂貴的用于大規模的像素操作時。 ](qpaintengine.html) [**See also**](qpaintengine.html) [setPixel](qimage.html#setPixel)( )[valid](qimage.html#valid)()和[Pixel Manipulation](qimage.html#pixel-manipulation)。 ``` int QImage.pixel (self, int?x, int?y) ``` 這是一個重載函數。 返回該像素的顏色坐標(_x_,_y_) 。 ``` int QImage.pixelIndex (self, QPoint?pt) ``` 返回的像素指數在給定的_position_。 If _position_是無效的,或者如果圖像是不是一個調色板圖像([depth](qimage.html#depth)( ) \u003e 8 ) ,結果是不確定的。 **See also** [valid](qimage.html#valid)( )[depth](qimage.html#depth)()和[Pixel Manipulation](qimage.html#pixel-manipulation)。 ``` int QImage.pixelIndex (self, int?x, int?y) ``` 這是一個重載函數。 返回像素的索引(_x_,_y_) 。 ``` QRect QImage.rect (self) ``` [](qrect.html) [返回的包圍矩形( 0,0,](qrect.html)[width](qimage.html#width)( )[height](qimage.html#height)的圖像())。 **See also** [Image Information](qimage.html#image-information)。 ``` QImage QImage.rgbSwapped (self) ``` [](qimage.html) [返回](qimage.html)[QImage](qimage.html)在其中的所有像素的紅色和藍色分量的值被交換,有效地轉換為RGB圖像到一個BGR圖像。 原[QImage](qimage.html)不改變。 **See also** [Image Transformations](qimage.html#image-transformations)。 ``` bool QImage.save (self, QString?fileName, str?format?=?None, int?quality?=?-1) ``` 的圖像保存到文件中與給定的_fileName_,使用給定的圖像文件_format_和_quality_因素。如果_format_為0時,[QImage](qimage.html)將嘗試通過觀察來猜測格式_fileName_的后綴。 該_quality_因子必須介于0到100或-1 。指定0以獲得小的壓縮文件, 100為大型無壓縮文件,并-1(默認值)來使用默認設置。 返回True如果圖像保存成功,否則返回False 。 **See also** [Reading and Writing Image Files](qimage.html#reading-and-writing-image-files)。 ``` bool QImage.save (self, QIODevice?device, str?format?=?None, int?quality?=?-1) ``` 這是一個重載函數。 該函數將一個[QImage](qimage.html)為給定的_device_。 這可以,例如,可以用于圖像直接保存成[QByteArray](qbytearray.html): ``` [QImage](qimage.html) image; [QByteArray](qbytearray.html) ba; [QBuffer](qbuffer.html) buffer(&ba); buffer.open([QIODevice](qiodevice.html).WriteOnly); image.save(&buffer, "PNG"); // writes image into ba in PNG format ``` ``` QImage QImage.scaled (self, int?width, int?height, Qt.AspectRatioMode?aspectRatioMode?=?Qt.IgnoreAspectRatio, Qt.TransformationMode?transformMode?=?Qt.FastTransformation) ``` [ 返回圖像的縮放副本由給定定義的矩形_size_根據給定的_aspectRatioMode_和_transformMode_。 ![](https://img.kancloud.cn/e5/cd/e5cd6412df7e86ff33e3e15ff4d825a0_560x122.png) ](qimage.html) [](qimage.html) * [If _aspectRatioMode_ is](qimage.html) [Qt.IgnoreAspectRatio](qt.html#AspectRatioMode-enum), the image is scaled to _size_. * If _aspectRatioMode_ is [Qt.KeepAspectRatio](qt.html#AspectRatioMode-enum), the image is scaled to a rectangle as large as possible inside _size_, preserving the aspect ratio. * If _aspectRatioMode_ is [Qt.KeepAspectRatioByExpanding](qt.html#AspectRatioMode-enum), the image is scaled to a rectangle as small as possible outside _size_, preserving the aspect ratio. 如果給定的_size_是空的,這個函數返回一個空的圖像。 **See also** [isNull](qimage.html#isNull)()和[Image Transformations](qimage.html#image-transformations)。 ``` QImage QImage.scaled (self, QSize?size, Qt.AspectRatioMode?aspectRatioMode?=?Qt.IgnoreAspectRatio, Qt.TransformationMode?transformMode?=?Qt.FastTransformation) ``` [ 這是一個重載函數。 返回圖像的縮放,以一個矩形與給定的副本_width_和_height_根據給定的_aspectRatioMode_和_transformMode_。 如果任何一個_width_或_height_為零或負數,則該函數返回一個空的圖像。 ](qimage.html) ``` QImage QImage.scaledToHeight (self, int?height, Qt.TransformationMode?mode?=?Qt.FastTransformation) ``` [ 返回圖像的縮放復印。返回的圖像被縮放為給定的_height_使用指定的變換_mode_。 這個函數自動計算的圖像的寬度,以使圖像的比率被保持。 如果給定的_height_為0或負數,則返回一個空的圖像。 ](qimage.html) [**See also**](qimage.html) [Image Transformations](qimage.html#image-transformations)。 ``` QImage QImage.scaledToWidth (self, int?width, Qt.TransformationMode?mode?=?Qt.FastTransformation) ``` [ 返回圖像的縮放復印。返回的圖像被縮放為給定的_width_使用指定的變換_mode_。 這個函數自動計算圖像的高度,使得其高寬比被保存下來。 如果給定的_width_為0或負數,則返回一個空的圖像。 ](qimage.html) [**See also**](qimage.html) [Image Transformations](qimage.html#image-transformations)。 ``` sip.voidptr QImage.scanLine (self, int) ``` 返回一個指針,指向像素數據與索引掃描線_i_。第一個掃描行的索引為0 。 該掃描線數據是對齊的32位邊界。 **Warning:**如果您正在訪問32位色的圖像數據,轉換返回的指針`QRgb*`([QRgb](qcolor.html#QRgb-typedef)有一個32位的大小) ,并用它來讀取/寫入的像素值。你不能使用`uchar*`直接指針,因為像素格式依賴于底層平臺上的字節順序。使用[qRed](index.htm#qRed)( )[qGreen](index.htm#qGreen)( )[qBlue](index.htm#qBlue)()和[qAlpha](index.htm#qAlpha)()來訪問的像素。 **See also** [bytesPerLine](qimage.html#bytesPerLine)( )[bits](qimage.html#bits)( )[Pixel Manipulation](qimage.html#pixel-manipulation)和[constScanLine](qimage.html#constScanLine)( ) 。 ``` int QImage.serialNumber (self) ``` ``` QImage.setAlphaChannel (self, QImage?alphaChannel) ``` ``` QImage.setColor (self, int?i, int?c) ``` 設置顏色在給定的_index_在顏色表中,給定到_colorValue_。顏色值是一個ARGB四胞胎。 If _index_在顏色表的當前大小之外,它與擴展[setColorCount](qimage.html#setColorCount)( ) 。 **See also** [color](qimage.html#color)( )[colorCount](qimage.html#colorCount)( )[setColorTable](qimage.html#setColorTable)()和[Pixel Manipulation](qimage.html#pixel-manipulation)。 ``` QImage.setColorCount (self, int) ``` 調整大小,顏色表包含_colorCount_條目。 如果顏色表被擴展時,這些額外的顏色將被設置為透明的(即qRgba (0,0 ,0,0 ))。 當圖像被使用時,顏色表必須足夠大,以對所有存在于圖像中的像素/索引值的條目,否則結果是不確定的。 此功能被引入Qt的4.6 。 **See also** [colorCount](qimage.html#colorCount)( )[colorTable](qimage.html#colorTable)( )[setColor](qimage.html#setColor)()和[Image Transformations](qimage.html#image-transformations)。 ``` QImage.setColorTable (self, list-of-int?colors) ``` 設置用來翻譯的顏色索引顏色表[QRgb](qcolor.html#QRgb-typedef)值,與指定_colors_。 當圖像被使用時,顏色表必須足夠大,以對所有存在于圖像中的像素/索引值的條目,否則結果是不確定的。 **See also** [colorTable](qimage.html#colorTable)( )[setColor](qimage.html#setColor)()和[Image Transformations](qimage.html#image-transformations)。 ``` QImage.setDotsPerMeterX (self, int) ``` 設置適合于水平方向的物理米的像素的數目,以_x_。 再加上[dotsPerMeterY](qimage.html#dotsPerMeterY)(),這個數定義期望的規模和圖像的縱橫比,并確定比例在其中[QPainter](qpainter.html)將在圖像上繪制圖形。它不改變時,它是在其他繪圖設備上呈現的圖像的比例或縱橫比。 **See also** [dotsPerMeterX](qimage.html#dotsPerMeterX)()和[Image Information](qimage.html#image-information)。 ``` QImage.setDotsPerMeterY (self, int) ``` 設置適合垂直于一個物理米的像素的數目,以_y_。 再加上[dotsPerMeterX](qimage.html#dotsPerMeterX)(),這個數定義期望的規模和圖像的縱橫比,并確定比例在其中[QPainter](qpainter.html)將在圖像上繪制圖形。它不改變時,它是在其他繪圖設備上呈現的圖像的比例或縱橫比。 **See also** [dotsPerMeterY](qimage.html#dotsPerMeterY)()和[Image Information](qimage.html#image-information)。 ``` QImage.setNumColors (self, int) ``` ``` QImage.setOffset (self, QPoint) ``` 設置由所述圖像的目的是當定位相對于其他圖像,以此作為偏移量的像素數_offset_。 **See also** [offset](qimage.html#offset)()和[Image Information](qimage.html#image-information)。 ``` QImage.setPixel (self, QPoint?pt, int?index_or_rgb) ``` 設置在像素索引或顏色在給定的_position_至_index_or_rgb_。 如果圖像的格式可以是單色或8位,在給定_index_or_rgb_值必須是一個索引圖像的顏色表,否則該參數必須是一個[QRgb](qcolor.html#QRgb-typedef)值。 If _position_不是一個有效的坐標對圖像中,或者如果_index_or_rgb_\u003e =[colorCount](qimage.html#colorCount)( )在單色和8位圖像的情況下,結果是不確定的。 **Warning:**這個功能是昂貴的,由于內部的呼叫`detach()`函數調用中,如果性能是一個問題,我們建議使用[scanLine()](qimage.html#scanLine)以直接訪問的像素數據。 **See also** [pixel](qimage.html#pixel)()和[Pixel Manipulation](qimage.html#pixel-manipulation)。 ``` QImage.setPixel (self, int?x, int?y, int?index_or_rgb) ``` 這是一個重載函數。 設定像素索引或顏色的(_x_,_y_)至_index_or_rgb_。 ``` QImage.setText (self, QString?key, QString?value) ``` 設置圖像的文字給定的_text_并將它與給定的關聯_key_。 如果你只是想存儲一個單一的文本塊(即“注釋”或只是一個描述) ,你可以傳遞一個空鍵,或使用如“描述”一個通用密鑰。 圖像的文字嵌入到圖像數據,當你調用[save](qimage.html#save)()或[QImageWriter.write](qimagewriter.html#write)( ) 。 不是所有的圖像格式支持嵌入式文本。你可以發現,如果一個特定的圖像格式,或通過使用支持嵌入文本[QImageWriter.supportsOption](qimagewriter.html#supportsOption)( ) 。我們舉一個例子: ``` [QImageWriter](qimagewriter.html) writer; writer.setFormat("png"); if (writer.supportsOption([QImageIOHandler](qimageiohandler.html).Description)) qDebug() << "Png supports embedded text"; ``` 您可以使用[QImageWriter.supportedImageFormats](qimagewriter.html#supportedImageFormats)()來找出哪些圖像格式提供給您。 **See also** [text](qimage.html#text)()和[textKeys](qimage.html#textKeys)( ) 。 ``` QSize QImage.size (self) ``` [](qsize.html) [返回的圖像的尺寸,即其](qsize.html)[width](qimage.html#width)()和[height](qimage.html#height)( ) 。 **See also** [Image Information](qimage.html#image-information)。 ``` QImage.swap (self, QImage?other) ``` 掉期圖像_other_與此圖像。這個操作是非常快的,而且永遠不會。 此功能被引入Qt的4.8 。 ``` QString QImage.text (self, QString?key?=?QString()) ``` 返回與給定關聯的圖像文本_key_。如果指定的_key_是一個空字符串,則返回整個圖像的文字,每個按鍵文對用換行分隔。 **See also** [setText](qimage.html#setText)()和[textKeys](qimage.html#textKeys)( ) 。 ``` QStringList QImage.textKeys (self) ``` 返回文本鍵這一形象。 您可以使用這些按鍵與[text](qimage.html#text)( )列出圖像文本的某些關鍵。 **See also** [text](qimage.html#text)( ) 。 ``` QImage QImage.transformed (self, QMatrix?matrix, Qt.TransformationMode?mode?=?Qt.FastTransformation) ``` [ 傳回的圖像,是利用給定的變換轉化副本_matrix_改造_mode_。 ](qimage.html) [改造_matrix_在內部進行調整,以補償不希望的翻譯,即所產生的圖像是包含原始圖像的所有變換的點的最小圖像。使用](qimage.html)[trueMatrix](qimage.html#trueMatrix)()函數來檢索用于轉化的圖像的實際的矩陣。 **See also** [trueMatrix](qimage.html#trueMatrix)()和[Image Transformations](qimage.html#image-transformations)。 ``` QImage QImage.transformed (self, QTransform?matrix, Qt.TransformationMode?mode?=?Qt.FastTransformation) ``` [ 傳回的圖像,是利用給定的變換轉化副本_matrix_改造_mode_。 ](qimage.html) [改造_matrix_在內部進行調整,以補償不希望的翻譯,即所產生的圖像是包含原始圖像的所有變換的點的最小圖像。使用](qimage.html)[trueMatrix](qimage.html#trueMatrix)()函數來檢索用于轉化的圖像的實際的矩陣。 不像其他的過載時,此功能可用于對圖像進行透視變換。 **See also** [trueMatrix](qimage.html#trueMatrix)()和[Image Transformations](qimage.html#image-transformations)。 ``` QMatrix QImage.trueMatrix (QMatrix, int?w, int?h) ``` [ 返回用于轉化的圖像與給定的實際的矩陣_width_,_height_和_matrix_。 ](qmatrix.html) [當使用變換的圖像的](qmatrix.html)[transformed](qimage.html#transformed)()函數,該變換矩陣是在內部調整以補償不需要的翻譯,即[transformed](qimage.html#transformed)( )返回一個包含原始圖像的所有變換的點的最小圖像。這個函數返回修改后的矩陣,正確映射點從原始圖像到新的形象。 **See also** [transformed](qimage.html#transformed)()和[Image Transformations](qimage.html#image-transformations)。 ``` QTransform QImage.trueMatrix (QTransform, int?w, int?h) ``` [ 返回用于轉化的圖像與給定的實際的矩陣_width_,_height_和_matrix_。 ](qtransform.html) [當使用變換的圖像的](qtransform.html)[transformed](qimage.html#transformed)()函數,該變換矩陣是在內部調整以補償不需要的翻譯,即[transformed](qimage.html#transformed)( )返回一個包含原始圖像的所有變換的點的最小圖像。這個函數返回修改后的矩陣,正確映射點從原始圖像到新的形象。 不像其他的過載,此功能創建可用于上的圖像進行透視變換變換矩陣。 **See also** [transformed](qimage.html#transformed)()和[Image Transformations](qimage.html#image-transformations)。 ``` bool QImage.valid (self, QPoint?pt) ``` 返回True如果_pos_是一種有效的坐標在圖像內對;否則返回False。 **See also** [rect](qimage.html#rect)()和[QRect.contains](qrect.html#contains)( ) 。 ``` bool QImage.valid (self, int?x, int?y) ``` 這是一個重載函數。 返回True如果[QPoint](qpoint.html)(_x_,_y_)是一個有效的坐標在圖像內對;否則返回False。 ``` int QImage.width (self) ``` 返回圖像的寬度。 **See also** [Image Information](qimage.html#image-information)。 ``` bool QImage.__eq__ (self, QImage) ``` ``` bool QImage.__ne__ (self, QImage) ```
                  <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>

                              哎呀哎呀视频在线观看