I am working on application which needs to load bmp 16bit(5-6-5) images to QPixmap. Is there any way in Qt of doing this directly like for 24bit bmp's?
I tried to convert all images to 24bit version and there were no problems with loading them. Unfortunately I really need to work with 16bit.
I tried also the following code, but without success. However I could load 16bit (1-5-5-5) version of my bmp.
QImage img = QImage(300, 300, QImage::Format_RGB16);
img.loadFromData(imgArray);
ui->test->setPixmap(QPixmap::fromImage(img));
It seems to work pretty well for me using the QImage constructor:
QImage::QImage(const QString & fileName, const char * format = 0)
Basically, the use would be:
QImage img = QImage("filename.bmp")
and the RGB16 format should be picked up by the constructor on its own from the file header.
EDIT:
The file you posted seems to be using a header type that is not supported by Qt. It is an undocumented header with size 56 called BITMAPV3INFOHEADER, which Wikipedia explains as:
Not officially documented, but this documentation was posted Adobe's
forums, by an employee of Adobe with a statement that the standard was
at one point in the past included in official MS documentation
https://forums.adobe.com/message/3272950#3272950
It seems to be a quite special header type that is not supported by many libraries. However, gimp or ImageMagic can load it and convert it, so I suggest that you converted your files to another BMP file with RGB565 encoding that uses a more standard header. Then, the above code will work for you.
Related
Im learning web3, and while examining the source code of a page, I saw that the abi file was written in a strange way, what is it? how can i decode?
I assumed it was hexcode and tried to convert it..
http://ddecode.com/hexdecoder/
it didn't work
ABIs are JSON files. JSON stands for JavaScript Object Notation, and is a commonly-used data transfer format. Here's an introduction to JSON: https://www.w3schools.com/whatis/whatis_json.asp
Here's a quick description of ABIs: https://ethereum.stackexchange.com/a/235/97038
EDIT: It appears that the file you're looking at is obfuscated: https://blog.jscrambler.com/javascript-obfuscation-the-definitive-guide
I have a file (about 100k files, to be specific) containing a data from weather radars - one file is a one radar image. It is a mosaic of data from several radars, creating a map of a reflectivity over whole country.
The files have extension .cmax and I need to convert them to something more useful (eg. array of reflectivities) for further uses.
I have asked data provider how to read those files. They responded:
The standard product format in our system (.cmax) is the internal format of the company that provides us with the software. It consists of an xml and binary part. It can be read by reading as a stream of bytes. Firstly, parse the initial bytes as xml, then treat the rest (BLOBs) as a binary data compressed with the "qt" method. You need to unpack them using a library that supports this compression mode. In general, you have to work a little, but it can be done in virtually any programming language.
The main issue is with the binary part of data. I have tried to decompress it with zlib (googling qt compression it comes out) and reading as a binary data in C++. None of them worked. It also doesn't seem resonable to me to try reading that data as binary in Qt.
The file begins with those lines:
<product version="5.44.5" datetime="2017-01-01T18:00:00" datatype="dBZ" type="cmax" name="CMAX" owner="">
<data time="18:00:00" date="2017-01-01">
Then, there are radars specifications and image details (active radars, min and max reflectivity etc). XML part ends with:
</product>
<!-- END XML -->
<BLOB blobid="0" size="79617" compression="qt">(here are lots of binary data)</BLOB>
I'm looking for a way (tool?) to convert that binary data. For example, it could be that mentioned library.
Looking at the details, this is most likely Leonardo (Selex/Gematronic) Rainbow5 format. zlib is the right lib for decompression. But there are some tricks to it. A python reader is implemented in the wradlib library (https://github.com/wradlib). Maybe you can adapt from that code. Disclaimer: I'm one of the wradlib devs.
Did you try simply using the qUncompress() function? https://doc.qt.io/qt-5/qbytearray.html#qUncompress
I can bring up a web page, no problem. I can save the webpage...as html, no problem. I need to save the webpage as mht so I can can get all the html that gets hidden without saving as mht. In researching I'm coming up with absolutely nothing as to how to save as mht using python. Like I said above I can try to save it as a mht file, using the standard coded for saving as html but that simply doesn't work...not surprised it doesn't work either, but it was worth a shot.
url = 'https://www.thewebsite.com'
html = urllib.request.urlopen(url).read()
m = open('websitetest.mht', 'w')
m.write(str(html))
m.close()
The site I'm trying to save does 'hidden code' that comes across when saved as mht, but not when saved as html. Hence why I'm trying to save as mht so I get all the code and then can go through the code to pull off what I need to compile a database.
There is a very handy Github project coded in Python 2.7 (you need to make simple modifications to make it compatible with Python 3.4). This project has code for packing/unpacking MHT files. I think this is what you are looking for:
Un/packs an MHT (MHTML) archive into/from separate files, writing/reading them in directories to match their Content-Location.
Recently came accross the same issue,
I wanted to convert html page to mht format.
Followed Tim Golden's Python stuff and was able to achieve it using win32com.
http://timgolden.me.uk/python/win32_how_do_i/create-an-mhtml-archive.html
import win32com.client as win32
URL = r'C:\WorkSpace\chetan_index.html' # issues found 1> One while using local files, pass the path in url format like file://directory01/directory02/index.html with %20 formating for special characters
# 2> Also same to be followed for files reffered internally inside html file i.e. src="file://reference/directory01/smiley.png"
# 3> Rare issue, if alt tag is found with src, images are not embedded into mht coreectly, trying poping alt tag from web page and then call CreateMHTMLBody
message = win32.gencache.EnsureDispatch('CDO.Message')
message.CreateMHTMLBody(URL, 0) # 0 - suppress none , download all images and others
stream = win32.gencache.EnsureDispatch(message.GetStream())
stream.SaveToFile(r'C:\temp\saved_mht.mht', 2) # 2, for overwrite existing file, 1 for not to overwrite
stream.Close()
I'm currently attempting to convert some PCL files into PDF using GhostPCL (PCL6).
For the most part this works. However, there is an odd problem with some of the conversion. For some reason, PCL6 is not converting some logos where are at the top of our documents. The logo is of the format:
^[(25XABCDEFGHIJKLMNOPQ^[(3#^M
^[(25X^[&a+1.49RRSTUVWXYZ[\]^_`ab^[(3#^M
^[(25X^[&a+1.49Rcdefghijklmnopqrs^M
when viewing the PCL file in vim. When printing the file as a PCL file, the image prints out correctly, but when converting to pdf, the following takes it's place:
ABCDEFGHIJKLMNOPQ
RSTUVWXYZ[\]^_`ab
cdefghijklmnopqrs
I recognize that the format is meant to be matched against some sort of embedded image or font, but it has been really difficult trying to find useful documentation on PCL (so I can actually figure out what these characters mean) or the conversion process.
Can anyone offer some insight on how to approach the conversion? We will need these images/logos in the converted documents since they often contain disclaimer information as part of the image.
EDIT1: I've also attempted converting to postscript and printing then and the same behavior occurs.
EDIT2: When rendering the PCL file in a viewer, the same text shows up instead of the image. But when printing, the logo does show up. Strange...
EDIT3: To clarify, sending the PCL file to a printer directly does not seem to cause the problem (i.e, the logo does print correctly). It's only when I attempt to convert it to another file format that the problem occurs.
What happens when you try rendering the PCL input with Ghostscript ? Eg to the display device. If it doesn't render its not going to end up in a PDF either.
Have you tried printing the file to a PCL printer ?
If it works to a PCL printer, but not when rendering you can open a bug against ghostpcl. If it renders but does not end up in the PDF then you can open a bug against ghostspcl with the 'pdf writer' component.
Its possible that the logo is shown using a rasterop, this is a part of the PCL imaging model which has no counterpart in PDF and so cannot be reproduced. The result of using a rasterop with the PDF device is variable, sometimes it will do what you expect, often it will not.
I am making a Qt application (4.7). Is there a way to split a file easily with QFile so that if I have a file x, I can split it equally into n parts fileX1, fileX2, ... fileXn?
As far as I know there is no in-build QFile method to split an existing file.
Depending on your use-case you can easily read the file into a QByteArray, split that into n parts and save those back to disc. (If you want an example of how to do that, just comment to this answer.)
There used to be an option to configure Qt, to build it with "large file support". Just Google for "qt large file support" (without the quotes), to see many references to this.
But I can't find any mention of this in the the Qt 4.7 Installation guide.
However, the option -no-largefile is mentioned in the page Platform and Compiler Notes - X11.