bmp qimage 保存位_在Qt中保存QImage(Save a QImage in Qt)
在Qt中保存QImage(Save a QImage in Qt)
是否可以導出Qt創建者生成的圖像? qimage是Qt中內置的數據類型。 我們使用setpixel()函數修改它。 我想保存該圖像以供進一步使用。
Is it possible to export images generated in Qt creator? The qimage which is a built in data type in Qt. We modify it using setpixel() function. I want to save that image for further use.
原文:https://stackoverflow.com/questions/27958716
2019-06-06 11:06
滿意答案
您可以使用
bool QImage::save ( const QString & fileName, const char * format = 0, int quality = -1 ) const
保存你的QImage
使用給定的圖像文件格式和品質因數將圖像保存到具有給定fileName的文件。 如果format為0,QImage將嘗試通過查看fileName的后綴來猜測格式。
品質因數必須在0到100或-1的范圍內。 指定0以獲取小型壓縮文件,指定100表示??大型未壓縮文件,使用-1(默認值)使用默認設置。
如果圖像成功保存,則返回true; 否則返回false。
You can use
bool QImage::save ( const QString & fileName, const char * format = 0, int quality = -1 ) const
To save your QImage
Saves the image to the file with the given fileName, using the given image file format and quality factor. If format is 0, QImage will attempt to guess the format by looking at fileName's suffix.
The quality factor must be in the range 0 to 100 or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed files, and -1 (the default) to use the default settings.
Returns true if the image was successfully saved; otherwise returns false.
2015-01-15
相關問答
您可以使用 bool QImage::save ( const QString & fileName, const char * format = 0, int quality = -1 ) const
保存你的QImage 使用給定的圖像文件格式和品質因數將圖像保存到具有給定fileName的文件。 如果format為0,QImage將嘗試通過查看fileName的后綴來猜測格式。 品質因數必須在0到100或-1的范圍內。 指定0以獲取小型壓縮文件,指定100表示大型未壓縮文件,使用-1(默認...
顯示如何顯示QImage的簡單但完整的示例可能如下所示: #include
#include
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QImage myImage;
myImage.load("test.png");
QLabel myLabel;
myLabel.setPixmap(QPixmap::fro...
從QImage文檔: 因為QImage是QPaintDevice子類,所以可以使用QPainter直接繪制到圖像上。 在QImage上使用QPainter時,可以在除當前GUI線程之外的另一個線程中執行繪制。 只需在您的圖像上創建一個QPainter并繪制您需要的內容。 From documentation of QImage: Because QImage is a QPaintDevice subclass, QPainter can be used to draw directly onto...
確保您沒有使用有損格式(例如JPEG)進行保存。 Make sure you're not saving using a lossy format, such as JPEG.
事實證明,在將圖像保存到bmp之前,Qt強制轉換圖像。 qt-src / src / gui / image / qbmphandler.cpp:777 : bool QBmpHandler::write(const QImage &img)
{
QImage image;
switch (img.format()) {
case QImage::Format_ARGB8565_Premultiplied:
case QImage::Format_ARGB8555_...
來自QImage::QImage(int width, int height, Format format)的文檔QImage::QImage(int width, int height, Format format) : 警告:這將創建一個包含未初始化數據的QImage。 在使用QPainter繪制圖像之前,調用fill()以使用適當的像素值填充圖像。 因此,在構建圖像后,請在圖像上調用QImage::fill(uint pixelValue) 。 From the docs for QImag...
我用這種方式解決了這個問題: //This WON'T WORK due to problems caused by presence of OpenCV library; it interferes with normal QImage loading from QResources
/*
QImage logoImage(":/images/Logo.png");
*/
//Read file rawly into RAM (workaround to OpenCV/QImage issue)...
謝謝切爾諾貝利! 我偶然得到了解決方案。 我在我的完整程序中嘗試了測試代碼并且運行良好。 這是因為PyQt的很多功能必須在使用它之前構造一個QGuiApplication 。 from PyQt5 import QtCore, QtGui, QtWidgets
import sys
app = QtWidgets.QApplication(sys.argv)
print(QtGui.QImageWriter.supportedImageFormats())
現在我們得到了完整支持的格式: [Py...
我會嘗試這樣的事情(即,加載圖像,創建相同大小的另一個圖像,繪制背景,繪制圖像): QImage image1("someFile.png");
QImage image2(image1.size());
image2.fill(QColor(Qt::white).rgb());
QPainter painter(&image2);
painter.drawImage(0, 0, image1);
image2.save("somefile.jpg", "JPG");
I'd try some...
簡短的回答: 在你的QImage構造函數中使用Format_RGB32而不是Format_Indexed8 。 詳細答案: Format_Indexed8使用手動定義的顏色表,其中每個索引表示一種顏色。 你必須為你的圖像創建自己的顏色表: QVector color_table;
for (int i = 0; i < 256; ++i) {
color_table.push_back(qRgb(i, i, i)); // Fill the color table with B...
相關文章
在使用jsp生成web圖片時遇到這個問題,這是源代碼中的一條語句,源代碼可以執行,可是一將源碼放入ec
...
Windowsis an extremely effective and a an efficient
...
http://gumstix.org/create-a-bootable-microsd-card.h
...
Open [Tomcat install dir]\tomcat-users.xmlfor editi
...
經常在維基百科等網站看到目錄列表,點擊鏈接會跳到具體的位置,小美眉一直在問是怎么做到的,其實挺簡單
...
http://spark-project.org/ 項目首頁 http://shark.cs.berk
...
這篇文件寫的非常好,推薦大家重溫一下: http://highscalability.com/blog
...
查看jQuery EasyUI的幫助說明,getSelected是獲取選中行的數據,但當我沒有選中當前
...
pro-du-cer n. 1. Someone from a game publisher who
...
Data Week: Becoming a data scientist Data Pointed,
...
最新問答
如果啟用了復制處理程序,請確保將其置于其中一個安全角色之后。 我見過人們做的另一件事是在不同的端口上運行admin。 最好在需要auth的頁面上使用SSL,這樣你就不會發送明確的密碼,因此管理和復制將發生在8443上,而常規查詢將在8080上發生。 如果您要簽署自己的證書,請查看此有用的SO頁面: 如何在特定連接上使用不同的證書? I didn't know that /admin was the context for SOLR admin because /admin does not re
第一:在您的樣本中,您有: 但是你在詢問 //td[@class=‘CarMiniProfile-TableHeader’] (注意TableHeader中的大寫'T')。 xpath區分大小寫。 第二:通過查詢// td [@ class ='CarMiniProfile-TableHeader'] / td,你暗示你在外部td中有一個'td'元素,而它們是兄弟姐妹。 有很多方法可以在這里獲得制作和模型
這是你的答案: http://jsfiddle.net/gPsdk/40/ .preloader-container { position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; background: #FFFFFF; z-index: 5; opacity: 1; -webkit-transition: all 500ms ease-out;
問題是,在啟用Outlook庫引用的情況下, olMailItem是一個保留常量,我認為當您將Dim olMailItem as Outlook.MailItem ,這不是問題,但是嘗試設置變量會導致問題。 以下是完整的解釋: 您已將olMailItem聲明為對象變量。 在賦值語句的右側,在將其值設置為對象的實例之前,您將引用此Object 。 這基本上是一個遞歸錯誤,因為你有對象試圖自己分配自己。 還有另一個潛在的錯誤,如果之前已經分配了olMailItem ,這個語句會引發另一個錯誤(可能是
我建議使用wireshark http://www.wireshark.org/通過記錄(“捕獲”)設備可以看到的網絡流量副本來“監聽”網絡上發生的對話。 當您開始捕獲時,數據量似乎過大,但如果您能夠發現任何看起來像您的SOAP消息的片段(應該很容易發現),那么您可以通過右鍵單擊并選擇來快速過濾到該對話'關注TCP Stream'。 然后,您可以在彈出窗口中查看您編寫的SOAP服務與Silverlight客戶端之間的整個對話。 如果一切正常,請關閉彈出窗口。 作為一個額外的好處,wireshar
Android默認情況下不提供TextView的合理結果。 您可以使用以下庫并實現適當的aligntment。 https://github.com/navabi/JustifiedTextView Android Does not provide Justified aligntment of TextView By default. You can use following library and achieve proper aligntment. https://github.com/
你的代碼適合我: class apples { public static void main(String args[]) { System.out.println("Hello World!"); } } 我將它下載到c:\ temp \ apples.java。 以下是我編譯和運行的方式: C:\temp>javac -cp . apples.java C:\temp>dir apples Volume in drive C is HP_PAV
12個十六進制數字(帶前導0x)表示48位。 那是256 TB的虛擬地址空間。 在AMD64上閱讀wiki(我假設你在上面,對嗎?)架構http://en.wikipedia.org/wiki/X86-64 12 hex digits (with leading 0x) mean 48 bits. That is 256 TB of virtual address space. Read wiki on AMD64 (I assume that you are on it, right?) ar
這將取決于你想要的。 對象有兩種屬性:類屬性和實例屬性。 類屬性 類屬性對于類的每個實例都是相同的對象。 class MyClass: class_attribute = [] 這里已經為類定義了MyClass.class_attribute ,您可以使用它。 如果您創建MyClass實例,則每個實例都可以訪問相同的class_attribute 。 實例屬性 instance屬性僅在創建實例時可用,并且對于類的每個實例都是唯一的。 您只能在實例上使用它們。 在方法__init__中定
總結
以上是生活随笔為你收集整理的bmp qimage 保存位_在Qt中保存QImage(Save a QImage in Qt)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [Deep Learning]任意层cn
- 下一篇: 如何修复uefi引导?这种方法才是最有效