I want to load some images into a ListBox. These images are inside XAP.
Someone tell me that I can use ResourceManager, but I don't know how to get a list for all images inside a folder like "/Assets/Images/".
These images are added as Content.
Any advice?
If images are set to be content, then you can access them by their relative URLs. So, for example, in code-behind you could do something like this:
BitmapImage image = new BitmapImage(new Uri("/Assets/Images/image1.png",UriKind.Relative));
ImageControl.Source = image;
Same way you can reference them in XAML. However, on Windows Phone you cannot directly list them. You could have an XML file, for example, that keeps the names of existing images, and then read it and read images recursively.
You can't list the content resources - see List content files in a windows phone 7 app?. The workaround is to hardcode the list in your program.
To load the image see the examples under Application.GetResourceStream
Related
Im trying to check if a screenshot contains an image that is saved in the project resources, I need to find a 100% match only and would like to not use any extra libraries, now with that being said, I have no idea how to do so.
heres a few questions:,
do I compare the two buffered images together? do I change them into something else?
Il have to compare it atleast once a second or so. (just as general information)
I have a resource folder under my project in eclipse and the .png files are shown as text, is there a way to change that? I tried tinkering with the settings, no luck yet.
public static BufferedImage screenshot(){
BufferedImage capture = robot.createScreenCapture(screenSize);
return capture;
}
this is my screenshot, another bufferedimage is for example "compare", where the size of the compared image is smaller than the screenshot. how will I be able to check if the image contain the second image?
*For those who wondering, im trying to make a simple program that clicks a certain image once it pops up.
I have an application that allows the user to load and display images. In the QML front end I am using a fileDialog to get the file URLs which are then loaded using an image loader in C++.
The issue I have at the moment is that if you want to load multiple images you have to load them all at once because once the fileURLs changes, the old URLs are lost.
What is the best way to go about storing the URLs so that I can keep the images displayed?
solution 1:
C++ side, Use a QStringList or a QVector to store paths and load Images from it. Qml side, each time you get new URL push it back to your QStringList.
solution 2:
Declare a qml array (property var array:[]) and store in it the new urls, load images from this list.
I don't have much knowledge of imaging tools but I need to extract images contained within the layers of a psd file. I tried using GIMP with a "save all layers" plugin but that is just saving the root layers so I am ending up with just two .pngs. I need every image in a separate file with the correct sizes.
The reason I need the files is that I have been asking to create an animation with CSS using the images. An example animations is at http://srv1.contobox.com/frontend/ads/preview.html?id=981
The psd document I am trying to extract is
https://www.dropbox.com/sh/ud2eaesej08o0g3/AAAi-_pPHGESOFOBpA0uQfjta
The problem is that these files are structured with Layer Groups (I opened just one of them).
While GIMP is supporting open the file, the "save all layers" plug-in you are using probably is not aware of layer groups.
(BTW, GIMP unstable - the 2.9 development version is likely currently broken for opening PSDs - the image opens garbled there. It opens in gimp 2.8.10, though)
It is possible to save all layers - including sublayers, as separate images with an interaction in the Python console.
With you PSD being the only image open in GIMP, go to filters->python->console and type something along this:
img = gimp.image_list()[0] # retrieves a reference to the image
folder = "/tmp/" # folder of you choice for saving the files
counter = 0
def save_recurse(item):
global counter
if hasattr(item, "layers"):
for layer in reversed(item.layers):
save_recurse(layer)
else:
counter += 1
name = folder + "layer_%03d.png" % counter
pdb.gimp_file_save(img, item, name, name)
save_recurse(img)
(btw, I typed it here in a way you can just copy and paste the listing above in GIMP's Python console)
I have an old VB6 project which has a form containing a number of Image objects. That was the way the author had stored images to use on buttons etc. on other forms.
How can I extract the images from these objects to something like a JPG or BMP?
I was hoping for something to put into the Immediate window. I don't mind doing it one by one.
SavePicture MyImage.Picture, "mypic.bmp"
I have a set of small icons and hope to display them in my application when certain condition occurs, for example on sunny day, I display the sunny icon.
I can add the jpg files in the picture, and they seem to be uploaded to phone when I deploy the app. However, I don't know how to access these jpgs in my program.
Could someone help? Thanks a lot!
Check this post about content and resources: http://www.windowsphonegeek.com/tips/wp7-working-with-images-content-vs-resource-build-action
To summarize: You should mark your images with a Build Action of Content or Resource, preferably Content. Now you can reference the Content from your Xaml or in code.
If the Build Action for your image resources is set to Content, then you just specify the Source property for the Image control to the relative path to your images:
this._image.Source = new BitmapImage(
new Uri("/Images/myImage.jpg", UriKind.Relative"));
You can display pictures using the Image element:
<Image Source="/MyImage.png" Visibility="Visible"/>
If you want to switch images according to conditions then you can create multiple images and change each of their Visibility states - or (more preferable) you can create a single image element and change its Source.
Quite how you do this depends on whether you are using databinding or working directly with the UIElements in code behind.