I need to generate an imaged based on data returned from a WebService call within a PeriodicTask in a Windows Phone app (Mango+).
I've seen a few ways of doing it in the main app but nothing that seems to work from a Scheduled Task
It depends. If you're in a background agent, memory is precious. The libraries you load count against your allocation limit, too, so you have less than the advertised amount.
Do you have a base image that you're modifying? If so, avoid creating UI elements and try to work with a WriteableBitmap. There is a library (yes, memory, but it's incredibly useful) that provides useful methods for working with such images called WriteableBitmapEx.
If you're generating simple images from scratch, going the UserControl route is workable too.
Try this guide I've described on my blog:
http://suchan.cz/?p=110
Basically you have to create your own UserControl and then render it into image and save it either as jpg, without transparency, or as transparent png. Also make sure you use as low memory as you can in the Backgroud Agent, if you use more than 6MB in WP7 or 11MB in WP8, your periodic task will be killed without notice.
I use a utility called ImageTools to render a PNG from a user control (note, this is not my blog). I created a shared library, with references to ImageTools, ImageTools.IO.Png, and ImageTools.Utils. The shared library does all the heavy lifting. Then my background agent project references the shared library project, and in the ScheduledAgent.OnInvoke it calls into the shared library to do the work. I am on Windows Phone 8 but it seems to work very well.
Related
I have been working on Xamarin forms for a long time now but the thing that has always bugged me is what is the better approach to store images in xamarin forms.
I wanted to know which images should I use from PCL and which ones should I put in native resource files or is using PCL images a bad approach altogether.
I went through everything in Local Images and Embedded Images but found nothing related to the better approach among them or performance or anything as such.
At the end after all the research for almost a year I came to the conclusion that the Local Image approach suits me better, even with the case where I had to add it to all three native projects depending what I target.
Reason being the following:
When I use local images I have an option to place different images in different size folders i.e. HDPI, MDPI(Android) and #2x,#3x(iOS)
What the above point does for me is it selects the image it should pick as per the current devices resolution which cannot be achieved with EmbeddedResources
One possible solution to issue mention above was using SVG's but as everyone knows that if the image you are using needs to look pixel perfect SVG's are not your best option as they lose some details here an there as you use them in your mobile devices.
One more cheeky thing I did (but I like to share my dev secrets) was whichever Images in my application were only in one size for all resolutions and platform or at least two of them I incorporated them in the Shared code
Note: Embedded Resource takes a little more time to load then your native Local Images always consider that while using
So, I've done a bit of reading around the forums about AssetBundles and the Resources folder in Unity 3D, and I can't figure out the optimal solution for the problem I'm facing. Here's the problem:
I've got a program designed for standalone, that loads "books" full of .png and .jpg images. The pages are, at the moment, the same every time the program starts. At the start of the scene for any "book", it's loading all those images at once using www.texture and a path. I'm realizing now, however, that this is possibly an non-performant method for accessing things at runtime -- it's slow! Which means the user can't do anything for 5-20 seconds while the scene starts and the book's page images load up (on non-legendary computers). SO, I can't figure out which of the three things would be the fastest:
1) Loading one asset bundle per book (say 20 textures # 1 mb each).
2) Loading one asset bundle per page (1 mb each).
3) Either of the first two options, but loaded from the resources folder.
Which one would be faster, and why? I understand that asset bundles are packaged by unity, but does this mean that the textures inside will be pre-compressed and easier on memory at load time? Does the resources folder cause less load time? What gives? As I understand it, the resources folder loads into a cache -- but is it the same cache that the standalone player uses normally? Or is this extra, unused space? I guess another issue is that I'm not sure what the difference is between loading things from memory and storing them in the cache.
Cheers, folks...
The Resource folders are bundled managed assets. That means they will be compressed by Unity, following the settings you apply in the IDE. They are therefore efficient to load at runtime. You can tailor the compression for each platform, which should further optimize performance.
We make expensive use of Resources.Load() to pull assets and it performs well on both desktop and mobile.
There is also a special folder, called StreamingAssets, that you can use to put bundled un-managed assets. This is where we put the videos we want to play at runtime, but don't want Unity to convert them to the default ogg codec. On mobile these play in the native video player. You can also put images in there and loading them is like using WWW class. Slow, because Unity needs to sanitize and compress the images at load time.
Loading WWW is slower due to the overhead of processing asset, as mentioned above. But you can pull data from a server or from outside the application "sandbox".
Only load what you need to display and implement a background process to fetch additional content when the user is busy going through the first pages of each book. This would avoid blocking the UI too long.
Optimize the images to reduce the file size. Use tinypng, if you need transparent images, or stick to compressed JPGs
Try using Power of 2 images where possible. This should speed up the runtime processing a little.
ath.
Great answer from Jerome about Resources. To add some additional info for future searches regarding AssetBundles, here are two scenarios:
Your game is too big
You have a ton of textures, say, and your iOS game is above 100 mb -- meaning Apple will show a warning to users and prevent them from downloading over cellular. Resources won't help because everything in that folder is bundled with the app.
Solution: Move the artwork you don't absolutely need on first-run into asset bundles. Build the bundles, upload them to a server somewhere, then download them at runtime as needed. Now your game is much smaller and won't have any scary warnings.
You need different versions of artwork for different platforms
Alternative scenario: you're developing for iPhone and iPad. For the same reasons as above you shrink your artwork as much as possible to hit the 100 mb limit for iPhone. But now the game looks terrible on iPad. What do?
Solution: You create an asset bundle with two variants. One for phones with low res artwork, and one for tablets with high res artwork. In this case the asset bundles can be shipped with the game or sent to a server. At run-time you pick the correct variant and load from the asset bundle, getting the appropriate artwork without having to if/else everywhere.
With all that being said, asset bundles are more complicated to use, poorly documented, and Unity's demos don't work properly at times. So seriously evaluate whether you need them.
I am developing one Blackberry application. In that application i am using lot of images both downloading from server as well as inside application using images for designing image button. My application working fine until continuously using 3 to 4 minutes.After that my application performance was too bad. My question is how to optimize memory to improve my application performance?
Thanks in Advance.
A pure guess - you are keeping the downloaded images in RAM, even if you don't use them on your current screen. If this is the case, then try to save them to the file system and read only those you're actually use for the current screen.
Unfortunatelly we can only guess, while it'd be much better to do it in a professional way. First of all you should detect your real reason. For this you should monitor your app to see what kind of objects eat most of the memory. And also how memory state changes in time. I work in JDE and it has a built-in tool for such kind of monitoring: 'View' > 'Object Statistics' (or 'Memory Statistics'). To activate those items you have to start your app in debugger. When you know the reason, you can go further and actually fix your code.
Use Eclipse Blackberry plugin profiler to find out if its memory or cpu performance issues.
If there are images in resources you are using constantly for UI elements, it's better to load them on app start and save them into some static constants. This way you will save CPU from loading images from resources.
Also consider convert images in resources into PNG with the 565 colorspace
I want my program to be able to launch any Windows game, and while the user is playing it, intermittently display some text or pictures in some part of the game window. The game may be in windowed or full-screen mode. From what I have been able to figure out from online resources, this could be done using a graphics library that supports overlays and using Windows Hooks to keep track of the target application's window. In this context I have some questions.
Will the overlays affect the game's performance?
How will hooking the application affect performance?
Is there any other way one could achieve this? For example, how do you think PIX, the DirectX debugging and analysis tool, work?
Fraps is the archetypal example of doing this sort of thing to a fullscreen DirectX application from a third-party app. It works by hooking some system calls and inserting itself into the call-chain between an app and DirectX. There is some performance hit, but in general its minimal.
This page seems to have some details and sample code on how to hook the app in this way.
If I recall correctly, from other forum discussions (can't find the link at the moment. search for things like "how does fraps work", it's a popular question), Fraps hooks a few things to force the app to load its DLL, then hooks Present() calls and executes a device->Clear() call before calling the real Present(), with a list of small rectangles to set to a different color, which can spell out the FPS number that it displays. This has a minimal performance impact and is widely compatible with whatever rendering the app is doing. Overlaying a bitmap would be more complicated since it wouldn't be as easy to do at Present-time. Perhaps if you could hook EndScene, then you could do more, but you would have to be careful to not change the device state.
PIX has privileged access to the DirectX driver, so I wouldn't expect to be able to use that as a model to emulate.
If an the target app is running in windowed mode, hooking DirectX still work, but you could also just use GDI instead.
Edit: I think this is the link I was originally thinking of.
I am looking for a component that resizes and ftp's images to a website.
It doesn't have to be free.
In fact, I prefer something we pay for that comes with solid support.
It has to be able to transfer multiple images at once too.
We work in an ASP.NET MVC environment but the component could be in Flash or Java.
I've used Aurigma Image Uploader successfully in the past. However it doesn't support ftp'ing the uploaded files out of the box, but this could be easily done from the web server end ...
I've used imagemagick and netpbm. Both do excellent job of image manipulation. Since you didn't mention any language, I assume that you will use some kind of script to do both conversion and transfer. I would get everything resized first, and then ftp'ing (or scp, which is simpler to script)
Most are standalone vs. components, but might find something that fits the needs:
http://www.freedownloadscenter.com/Best/ftp-resize.html