How assert that a TIFF file conforms to standard? - qt

Today, I use FreeImage 3.15.4.0 to generate TIFF images. Some of my users tells me that he cannot read such images because its library (C++/QT I think) can't read them.
The images generated are readable with ImageJ and some other image processing tools.
So I wonder:
How to be sure that my image respect the standard (FreeImage rely on libtiff 4.0.3)?
Are my images too complex? (32 bits float images)
Does a simple standard format exist for 32 bits depth float images?
EDIT
I check by hand that my image followed the format described by adobe: http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf.
So, does exist a library comparative to know what part of specification is supported by which library?

Answer to 3 questions: yes.
The fact is QT, like others, is not able to display 32 bits float images: This is not supported by the QImage class (http://doc.qt.io/qt-5/qimage.html#Format-enum).
So the user will have to convert the image in something QT (the system in fact) is able to display.

Related

Thumbnail extraction from videos using Qt/C++

how to get thumbnail image from the video file using Qt/C++.i use TagLib ,its not worked out.
You can use the libVLC or ffmpeg, it's more easily than using Qt
Basically any Video is in 'frame' and that frame is you thumbnail.
We can image like box, where inside of box are all information about 'image' like where is positioned (in time), how big it is (Full HD, 720 ...), and all other sort of information.
Biggest question is what video format you like to extract, and how you like to extract.
For example file format like AVI is well known see:
how to read avi files
In case when you read som other format, you need to know how to read correctly in binary format, or you can use any library that will handle 'unpack format' for you.
Last question is if library can 'extract' image for 'this' frame ... but this is up to library.
To answer your question, you can use any external library, or read manually by yourself on binary level.
PS: If TagLib is not working for you can try any other library, just make sure you read documentation and try to find is library allow you to get images from frames.

How to view floating-point image on the web asp.net?

Is there any way to display floating point image on web form?
Alternatively, I would like to search for an algorithm to convert floating point image into a PNG or JPEG format.
I am looking for an open source project.
It depends very much on the format of the floating point imagery.
If you have straight uncompressed RGBA floats you can simply iterate over them using unsafe methods to clamp the float values to byte values and fill up the pixels of a dotnet bitmap which has been locked using the lockbits method.
For more information on lockbits see this article by Bob Powell.
If the floating point data is not uncompressed or not in a known or accessible format, you might try an open source library such as FreeImage.NET to open the image.

Cross-platform custom cursors for Qt, cursor in resource file

I feel like I'm missing something since I can't see any way to easily do a cross-platform cursor in Qt. That is, I'd like to use a standard cursor editor, or just a common cursor file type, and stick it in the resource file.
I see a couple platform specific manners providing handles (meaning I couldn't load from a resource) or a generic way taking a pixmap. In the pixmap method I would then have to find someway to store the hotspot along with the pixmap.
I don't want animated cursors, just a plain color image (32x32).
What is the easiest way to handling this?
I'm currently working on an application where I'd like to have some nice custom cursors. The way I'm doing that is:
Add an image to a Qt resource file (*.qrc) - I am working with PNG with transparency exported from an SVG (always have your original art sources in SVG for things like this in case you need scaling)
<RCC>
<qresource prefix="/">
<file alias="default">cursors/cursor_default.png</file>
</qresource>
</RCC>
This will allow you to ship your cursors along with your application since Qt resource files are converted to C++ sources, which are then added to your binary
In your source code do:
QPixmap cursor_pixmap = QPixmap(":cursor_default");
QCursor cursor_default = QCursor(cursor_pixmap, 0, 0);
setCursor(cursor_default);
There are two important things to notice here both related to the constructor of the QCursor - the pixmap you add to it and the hotspot coordinates (here both set to 0 which is the top left corner of the pixmap that represents the shape of your cursor). There are actually 2 constructors for QCursor which are imho useful here:
- `QCursor::QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX = -1, int hotY = -1)` - this allows you to use a mask to manipulate the pixels of your cursor
- `QCursor::QCursor(const QPixmap &pixmap, int hotX = -1, int hotY = -1)` - if you are working with a PNG or other supported image format which allows transparency you can omit the mask as it is in my case.
The hotspot is a very essential part of a cursor - it tells your application which part of your cursor is the "trigger" that is the spot which does something compared to the rest which is just fancy visuals and nothing functional.
While looking for resources on Qt customization of cursors I found this article (the image above is from it), which I can totally recommend every one, interested in this topic, to read.
In terms of storing the hotspot I don't think that something like this is necessary. After all your resource files are compiled and added to the binary hence when you assign a hotspot to a cursor inside your code it will be there. I doubt that any OS actually has a format (let alone multi-platform one) that stores both the cursor and its hotspot due to the fact that depending on the application you may want to change the hotspot (for example due to scaling the bitmap itself in order to have multiple sizes) which would be a lot more difficult if you have it bound to the cursor's bitmap. If you really want to go the distance with this (I would advise against it) you can create your own custom file format which contains both. Since the Qt resource files are - to my knowledge - meant for managing images you would have to implement the whole IO mechanics in order to support your custom format.
Hope this helps. The solution above is as cross-platform as you can get with the Qt framework. Note however that the custom QCursor will only be available inside your application and wherever you have set it in. Cursor that is above the window frame for example is considered OS-specific due to the fact that the window frame itself is an OS-specific feature and if you want to alter its behaviour you will have to go a lot deeper (and also outside Qt's safe zone) meaning check how cursors are handled on an OS-level.

image format best for display

I am working on an image processing application. I have to display an image sequence. I would like to avoid any extra overhead for {internal} format conversions.
I believe RGB should be the optimal format for display. But SDL accepts various YUV formats and there is no native{to SDL} support for RGB. Whereas Qt does not accept YUV format at all. X accepts RGBX format {native}. Images can be generated in any desired format for display. But CPU/GPU cycles for format conversion should be avoided. Any suggestion on what's the right way of displaying image sequences would be great.
The output format is ARGB. SDL works with RGB surfaces, so I don't understand your claim that "there is no native{to SDL} support for RGB.".
The native video acceleration interface of X only supports YUV input however. The YUV->RGB conversion on the GPU comes for free if you use the video acceleration interface. No "cycles" wasted here.
Perhaps you should go into more detail about your purposes. What is the framerate we are dealing with here?
I think you should use any uncompressed image + QPixmap.

Flex: Does the flex compiler automatically optimize embedded PNG assets?

I was trying to further reduce the filesize of a SWF file by optimizing the embedded PNG graphics (using ImageOptim tool). To my surprise, this didn't yield any effect, so I created two test Images:
Original (433883 bytes)
Optimized (273723 bytes)
When embedding either of these assets in a simple ActionScript project, the compiled SWF is ~274kb in size. Which raises the question: Does Flex optimize embedded PNG assets during compile-time? If yes, is there some documentation about the optimization going on?
It can't be because of the SWF compression alone, because zipping the images doesn't reduce filesize at all.
Here's the Code for completeness:
package
{
import flash.display.Sprite;
public class SizeTest extends Sprite
{
[Embed("/assets/original.png")]
private var ImageAsset:Class;
public function SizeTest(){
}
}
}
The answer is yes, the flex compiler does automatically compress data using one of the inbult algorithms (probably ZLIB) and transparently decompresses it on the other side (flash player) just before it gives you access to the uncompressed data.
I was embedding a ByteArray into an SWF, and although the bytes are huge outside (200 KB), when embedded into a SWF it turns into 30 KB, producing almost exactly the same results as manually compressing this using ByteArray.compress("zlib").
I then tried manually compressing PNG/JPEG bitmaps, and it turned out larger than embedding it plainly using the [Embed] tag (172 KB as a compressed ByteArray vs. 168 KB as an embedded image). Letting the Flex compiler handle embedded data compression is actually better than trying to do your own tricks on the ByteArray side.
Edit: To answer your question on PNG embedding, its hard to tell what's going on inside the flex compiler/flash player. Although known for proper documentation, Adobe is also known for many "undocumented features". Your specific question is best sent to a flash player architect (eg Tinic Uro) or an adobe evangelist (eg Lee Brimelow), some of whom you can easily reach on facebook (see this list).
The swf format has internally a special format for 32 bit PNGs (those with an alpha channel) where they get split up into a 24bit png and a greyscale alpha mask, whereby the alpha mask gets JPEG compressed. No totally sure if Flex Builder does that kind of optimization since I remember that at least in an older version embedded PNG where not at all optimized.
Nevertheless, if you are looking for a tool that can optimize embedded images in swfs you should check out Joa Ebert's "Reducer": http://blog.joa-ebert.com/2009/08/08/reducer/

Resources