I'm working on a solution for my new project (in C#). I'm trying to make a dynamic image/animation combiner (maybe later even work with video's, but that's not required atm).
So basically my program is reading a xml file with all kinds of instructions the user needs to do. In the xml file it is possible that for 1 instruction multiple pictures are needed. So when there are 2 or 3 pictures (the maximum amount of pictures is 4) they need to be combined to 1 picture so I can show that on the image object on the main form. Also it is important that the pictures keep there proportions so the image doesn't look deformed.
I found a solution with GDI+ but it isn't that good as I wanted it and runs pretty slow on a bit older computers. Also combining animations with normal images is a real pain and goes very slow!
Is there a faster/easier way to do this? Maybe WPF is a solution but I got no experience with this.
Thnx for any help in advance!
This questsion is open now for mor then a year but I found the solution some time ago so I will post it here in case it is usefull for somebody else.
The best way to do this was creating to set up a grid dynamic. And then fill up each element of the grid with the needed media (Video, Image, animated gif's and even Viewport3D from another xaml file). Creating a grid in code is really easy so it should be a good solution for everybody who wants to do this in WPF.
Related
I'm learning C# and I'm trying to make a basic application with Visual Studio.
One of the things I want to achieve is to download several weather maps from the Internet and make a loop with them (show one after the other after sorting them chronologically) so that you can see how the weather changes over time.
Downloading the images was quite simple, but now I can't decide what's the best approach (or at the least the most common) to show them one after the other.
Should I have one single PictureBox and change it's image over time?
Should I have several PictureBoxes one on top of each other and make them appear and dissapear over time?
Any other approach you would recommend?
Also... when I tried changing the image with a loop to get the effect I'm looking for (sleeping the app after each change for a second), the app takes 10 seconds to start (the whole loop) and I can only see the last image in the PictureBox.
This obviously has to do with the app being busy and not refreshing the form.
After googling a bit I saw that I could add a BackgroundWorker... is that correct? Should I go down that path or am I missing something completely?
Would you be able to give me a few clues on how would you approach this application? I don't necessarily need to see the code.
As you can see I'm only beginning to code in Visual Studio and trying to learn by trial and error, so I'm just looking for a bit of guidance.
Thanks a lot for the help!
There is a nice Tutorial called A Simple Image Slide Show
This should solve your problem
I've been trying to create a roll-playing game for a little over a year now, and I thought a good way to test it and flesh it out a bit would be to turn it into a Dungeons and Dragons variant. However, the inherent problem with using a DnD setup is that there's a lot to keep track of, to the point where it becomes impossible for a single person to do by themselves. As such, I thought of writing a C# program to help.
I ran into this problem when I tried using a series of PictureBox objects to represent the spaces on the map where characters can move. I wanted to use PictureBoxes because that would allow me to use images to represent terrain and characters occupying the given space. However, the map I am using is roughly 46 x 75 1-inch squares, totaling 3450 PictureBoxes. This, understandably, slows the application down so much that it actually freezes for minutes at a time while it redraws the map every so often.
I tried two solutions. First, I tried using a Panel object for its free scrolling capabilities in the hopes that the application wouldn't have to redraw the whole map, but rather only the subset of PictureBoxes visible at that time. This helped only a little, and not enough to make the application usable. Second, I looked online, including this forum, and found people having similar problems. However, the problems they were having were entirely unrelated to mine (aside from the whole slow redraw thing) and thus the solutions didn't really apply to me. I did see a few recurring lines that I tried:
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
I'm not really sure what they do, but they did help a bit. I am still seeing way too much lag, though.
I'm out of ideas at the moment. Is there a better control I could use or a different way of drawing? Thanks in advance for your help!
I would try to develop a solution that only renders the images that are visible on the screen at any given time. Images should only be rendered when you scroll them into focus.
This is a common technique since rendering UI is usually the slowest operation by far. I would bind a view model object to the visible objects, which means you only have to render a subset of the images instead of the entire screen.
Grids with endless scroll sometimes use this approach.
I'm developing a C# software that is able to show previews for files. Basically, there is a tree at the left that shows the disk filesystem entries, and a panel on the right that will show a preview of files selected in the tree, in a resizable panel that contains a docked PictureBox. Initially I only show preview for image files.
This software is designed for game developers, so I need to support all the image formats, I will use the great ImageMagick library for this purpose. The key is that some image files could be big, very big so, I have several questions, about performance and memory consumption.
Do I need to thread the load of the picture? Always, or only if the picture is very big?
Would be a correct if I load the picture directly in the Picturebox, or should I calculate a smaller size image (like a thumbnail or something similar), save it to disk, and then, show it?
Someone knows where can I download big picture files to test my preview with really very large files.
Imo always thread a work like this, there is little point in trying to decide what is big; for images that of are talking about I would of thought most would be enough that under the wrong conditions (computer is spending resources on other processes, not just yours) it could cause a perceivable pause in the UI thread.
Without knowing more, I would just test your implementation when it does the basic stuff and make a judgement call. There is also the question of required quality and desktop resolution of the user - so perhaps this should be configurable in some way.
Imo there could be no better place than PolyCount, specifically look in these forums:
http://www.polycount.com/forum/forumdisplay.php?f=42 &
http://www.polycount.com/forum/forumdisplay.php?f=60
I can place a couple of buttons in Silverlight, but I'm not that experienced with the Silverlight tools and capabilities.
What do you think I should use to create something like this?
The control would have to pull and ID from the database and according to that place an image asociated with the record.
I need it to be animated with some crispy movement.
How can I achieve this?
It's all possible, but you need to break the task down into smaller steps.
Once you've done that you should find that you can solve some of these with your current knowledge, others will resolve themselves with a little more research, but there will be some you need to ask questions about here.
I'd suggest you start that break down and try to solve the little problems. Then if you get stuck come back and ask more specific questions.
Well, with Silverlight and c# you can make the animations needed and such, and you can set a Silverlight Image control with a data bound source, so it loads the images dynamically, but Silverlight can't talk with databases directly, you'll need to use a webservice to interact between Silverlight and the database. Don't know how much you know but to not leave anything out, with Expression Blend you can make the graphical part of you're app fast and easy, and with Visual Studio you'll add the code-behind and functionality.
In this link you can find a example of how to make an image slide show with Silverlight, it may not be exactly what you're looking for, but it should give you a heads start.
Do you know of KeePass Password Safe 2? It's open-source and I'm trying to do some things but I've hit a dead end and can't find where the code is doing this and why it's doing it at all.
The source code is here and it's coded in C#:
http://downloads.sourceforge.net/keepass/KeePass-2.08-Source.zip
The problem is that the icons of the TreeView nodes and ListView entries are not properly rendered if the come from an alpha-blended PNG file. For instance, I created a 16x16 image and filled with a solid red color but with 50% transparency and saved it as PNG. Then added this icon to one of the TreeView nodes and KeePass displays this icon in a grayish color.
I'm not the author of this application as you know and can't post specific blocks of codes as I don't know which one might be causing the problem and like I said, I have no idea where this is coming from.
Can anybody help me out here?
EDIT:
I think I've found the issue here:
http://www.codeproject.com/KB/miscctrl/AlphaImageImagelist.aspx
I do use KeePass 2.x to store all my credentials. Haven't had a chance to look at the source code, though.
I think your question would be more suitable when asked in the KeePass forums. Maybe they're already working on a fix ? You might be also able to contribute to the development of the program.
This is more like an issue with the common controls KeePass is using rather than a problem in the KeePass code itself. A Google search turned up this page in the MSDN; there's a lot of duplicated posts but it seems to suggest that you need to set the EnableVisualStyles property on the form to get alpha transparency to work.