Qt: pull a section of image data on the fly - qt

I have a very large image(10000*10000) and for several reasons I cannot modify it (like chop it into smaller tiles.)
I don't want to display the whole image but a small section of it to improve the GUI efficiency.
But when the user click and drag it around, new part of image will be displayed in the viewport.
So, how could I pull a section of image data on the fly?

I don't recall Qt providing any support for working with partial images in case of really high resolutions. Maybe look into libtiff.
Basically, the image will be composed of either strips or tiles, so you can use the tiffreadscanline() or tiffreadencodedstrip() respectively to load portions of the image. The from that you can compose another image with the appropriate resolution for your viewport.
Alternatively, you could take a look at the QTiffHandler class, it is a private class in Qt so it is not directly accessible, but you could just copy it and if necessary modify the source to expose its functionality. Internally it uses libtiff as well.

Related

Use Image in various dynamically loaded Components in QML

What I want to Achive:
Toggling the appearance of an Item, where the components that describe the appearance are loaded dynamically, but common elements are not loaded multiple times.
Lets say, I have a list of elements with an icon (e.g. cover) and a title (e.g. music title).
When clicked/dragged, it shifts the shape, so additional information can be displayed (e.g. duration, artist, ...).
Finally I have a DropArea, in which I can drop those elements. Here I only want to display the icon.
As I am informed correctly, it is not advisable to have all three forms pre-loaded and only shift the visibility and other parameters of the additional objects, as the first list is a ListView.
Therefore I decided, to create multiple components, and then load them with a Loader.
On the other hand, this leads to some overhead, for I load and unload the Icon, that is common to all the components, each time, the shape shifts.
My solution so far is, to load the image outside of the components, re-parenting it each time, the shape shifts. This however feels odd, and I am not sure, if this might not be the less performing way, compared to the "loading everything at once and resetting visiblity and positioners"-approach
What is the proper way to do this?
For the efficiency aspect, the most performing one should be that only dynamically loads something that is really dynamic, and leaves other things static(or so called declarative). In your app, the icon should be declarative, I think.
Regarding with reparenting, actually re-parenting is quite common in Qt Quick programming, especially within dynamically loading context. The parent in Qt Quick is not the same concept of QObject. It's just visual management (not memory management). That's why you can see Qt Quick even provides ParentChange in State/Transition.

trying to make a bitmap editor in qt

I want to make a program using qt.
I have to make a bitmap editor for special purposes.
I had been looking widgets that could allow me to get this task done, one of them is QGraphicsView with QGraphicsScene.
As expected, I want my program to have many features.
They are listed below:
Exporting to image formats such as .bmp.
Support for clipboard, copy and paste. I hope this clipboard can be compatible with other similar programs.
The image must have a resolution. I mean the pixels of the screen can be bigger than the pixels of the image and vice-versa.
Selecting squared areas.
So, what I need to know is if I am using the correct widget. If not, which widget can I use? which are the member functions of the widget that I need to know?
There several ways to achieve what you want, but as your question is too broad, I would suggest looking at the Qt Scribble example and come back with specific questions relating to what it doesn't do.
The link suggested previously was replaced with a new one that points to the corresponding Qt 5 example.

Multi-Layered SWF with dynamic animation

I'm new to Flash and I trying to do something as following:
I need the ability run several layers of animation (image sequences) in a single file (ex. SWF) which will be loaded and accessed dynamically by Flex - I need to change the content (image sequence) in runtime in order to customize my animation.
What would be the best approach in this case?
Is it the correct direction?
Should I consider creating a SWF for each animation and load it dynamically into my layered SWF?
When you say you need to adjust the image sequence, do you mean customise the order of individual frames, or simply select between a selection of set sequences?
If it's the former, the answer will be a bit more in-depth, if it's the latter and there aren't too many you're probably best off exporting as SWFs, or even as a video file to compress them, then loading them in dynamically. If they're small enough not to add significant weight to your SWF, you could export them as MovieClips in a SWC and create instances of them directly in the code without having to load them in.
Hope this helps (sorry if any of the above is confusing!) - could you give a bit more detail on what you're trying to achieve?

Play flash one video on top of another?

I'm looking at a project that requires the ability to play one flash video over the top of another... sort of like an animated watermark, where the video on top has transparent regions ans may not be the same width/height as the one underneath.
Using Flash/Flex, can this be done in a web-app at real time? Or would you have to use an offline server app?
EDIT: This is not an HTML question. It's about making a simple video-editing kind of tool solely in Flex. Maybe I want to overlay a video of a galloping horse over a video of passing scenery or something. Ultimately, being able to output a single mixed video is useful, but for video editing that's too slow, real-time playback as the position of the overlay video is changed would be needed.
Hope this clarifies things somewhat?
Put the 2 videos on different layers inside your fla. The video files will have to be .flvs. Make sure the alpha channel is encoded in the video that's meant to go on top... this is done using your encoding program, like Flash Video Encoder. This is probably why it's not working for you right now.
I haven't done much flash work lately, but what I remember of flash (and I assume this is part of flex) you could draw in several files and place them on different levels, like a z-index.
If you need some sort of real-time keying or something of that nature, that is beyond my knowledge of flash.
You may be able to use CSS with z-indexing to do this through basic HTML/CSS means as well. But I would look to having flash do all the heavy lifting of layering, if you can.
I don't think you'll get such features,
Well, I am thinking, why you need to play flash files overlapped on each other .. If you want some water mark (static or Dynamic content), you can have it in a single flash file, you need not overlap the two files for that ..
Even if it was possible to make two flash files overlap on web-page, it is not recommended as good practice, because it needs lot of data to be transfered over to browser(in worst case, 2 files, so double the data), in-turn introducing more delay to load the page.. it is a degradation to your own web-page .. Instead try to merge files (image or flash) to save the amount of memory to be transfered via browser ..

Linking directly to a SWF, what are the downsides?

Usually Flash and Flex applications are embedded on in HTML using either a combination of object and embed tags, or more commonly using JavaScript. However, if you link directly to a SWF file it will open in the browser window and without looking in the address bar you can't tell that it wasn't embedded in HTML with the size set to 100% width and height.
Considering the overhead of the HTML, CSS and JavaScript needed to embed a Flash or Flex application filling 100% of the browser window, what are the downsides of linking directly to the SWF file instead? What are the upsides?
I can think of one upside and three downsides: you don't need the 100+ lines of HTML, JavaScript and CSS that are otherwise required, but you have no plugin detection, no version checking and you lose your best SEO option (progressive enhancement).
Update don't get hung up on the 100+ lines, I simply mean that the the amount of code needed to embed a SWF is quite a lot (and I mean including libraries like SWFObject), and it's just for displaying the SWF, which can be done without a single line by linking to it directly.
Upsides for linking directly to SWF file:
Faster access
You know it's a flash movie even before you click on the link
Skipping the html & js files (You won't use CSS to display 100% flash movie anyway)
Downsides:
You have little control on movie defaults.
You can't use custom background colors, transparency etc.
You can't use flashVars to send data to the movie from the HTML
Can't use fscommand from the movie to the page
Movie proportions are never the same as the user's window's aspect ratio
You can't compensate for browser incompetability (The next new browser comes out and you're in trouble)
No SEO
No page title, bad if you want people to bookmark properly.
No plugin information, download links etc.
If your SWF connects to external data sources, you might have cross domain problems.
Renaming the SWF file will also rename the link. Bad for versioning.
In short, for a complicated application - always use the HTML. For a simple animation movie you can go either way.
You also lose external control of the SWF. When it's embedded in HTML you can use javascript to communicate with the SWF. If the SWF is loaded directly that may not be possible.
Your 100+ lines quote seems pretty high to me. The HTML that FlashDevelop generates for embedding a SWF is only around 35 lines, with an include of a single swfobject.js file. You shouldn't need to touch the js file, and at the most would only have to tweak the HTML in very minor ways to get it to do what you want.
In my experience not all browsers handle this properly. I'm not really sure why (or which browsers) but I've mistakenly sent links like this to clients on occasion and they've often come back confused. I suspect their browser prompts them to download the file instead of displaying it properly.
One upside I can think of is being able to specify GET parameters in the direct URL to the SWF, which will then be available in the Flash app (via Application.application.parameters in Flex, not sure how you'd access them in Flash CS3). This can of course be achieved by other means as well if you have an HTML wrapper but this way it's less work.
Why would you need 100+ lines of code? Using something like swfobject reduces this amout quite some (and generally you don't want to do plugin detection, etc. by hand anyway).
More advantages:
Light weight look cuz you can get rid of the header with all the tool bars that seem to accumulate there and even the scroll bar is not needed. This enhances the impact when you are trying to show a lot of action in a short flash.
The biggie: you get it in a window that you can drag larger or smaller and make the movie larger and smaller. The player will resize the movie to fill the window you have. This is great for things like group photos where everyone wants to enlarge to find themselves and their friends. I've done this for a one frame Flash production!
Downsides:
As with popups in general, if you are asking for multiple ones from the same site, and you want different size popups, the browsers tend to simply override the size you ask for in window.open and reuse whatever is up. You need to close any open popup so the window.open will do a fresh create. It gets complicated, and I have not been able to get it to work across pages in a website. Anyone who has done this successfully, pls post how!
Adobe should be ashamed of themselves with the standard embed, which defeats the puprose of convention over configuration. Check ^swfobject (as mentioned above) or swfin

Resources