How to save a photo location or actual photo as a class variable? - xaml

I have a class with a variable named Photo. The user is using the PhotoChooserTask to select the photo, and it is being displayed in an Image control. This part of the application, the chooser and display, works fine.
I would like to save either the location/path of the chosen photo or the actual photo so that it will be available for display into an Image control when the user ran the application later.
The whole class is saved using serialization, and I don't know how to save/serialize the photo (or the photo path) that way.
The photo should be still available to the user through the Camera Roll as well.
Any help, link or code, would be greatly appreciated.

If you're using a PhotoChooserTask you will will get a PhotoResult instance from the PhotoChooserTask.Completed event.
You can then PhotoResult.ChosenPhoto stream and save the content to a byte array (easy serialization) or a file in Isolated Storage.

Related

phoenix: show image from aws s3

I study the phoenix, create an application that loads the image on aws s3, and then displays it. I was able to upload the image to the cloud, but now it is not clear how to display it to the user on the page (I do not want to make public link to these images in the cloud). I was looking for information on this issue, but did not find anything useful.
From the clouds I get the file as binary data. Do I need to create some of these data is a temporary file that will be displayed on the page? I can display the image as base64, but I think this is not the best way. I would appreciate advice.
Since you've already fetched the image to a binary, you can just send it directly to the client with the appropriate content type and the browser will render it as an image. For example, to fetch and send the png at https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png:
def index(conn, _params) do
image = HTTPoison.get!("https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png").body
conn
|> put_resp_header("content-type", "image/png")
|> send_resp(200, image)
end
If you open this in your browser, you'll see the image being rendered correctly because of the content-type header.

Android using build-in camera to capture multi-photos?

I want to ask whether the built-in camera to take photos and change the name in a specific folder.
Usually, we call this code to start built-in camera.
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
startActivityForResult( intent, 0 );
At onActivityResult(), we get the bitmap we just take and save it under a specific photo. As i know, it works for a single photo. However, if user takes many photos, can i get a list of these photo name??
Thanks all.
Each time a user takes a photo you must save it (under "onActivityResult()") with a different name so the last capture does now overwrite the previous. One easy solution is to concatenate in the photo name a timestamp so the photo name will become unique and it will be saved as a new photo.
If you want to get the list of those photos saved, you can use this example "android-coding.blogspot.gr/2011/10/list-filesdirectory-in-android.html"

How to upload photos using CakePHP 2.0

I'm developing a simple web app and I just want to allow the user to upload some pictures.
should I just store the picture url on my database table or should I upload the whole picture?
how can I validate the size of the picture being uploaded?
how can I upload the picture from my controller?
thank you all!
I would NOT store the image data in the database. I would create a Behavior that will upload the image to the image directory and store a reference to that image. The behavior can then handle size, mime type, etc. Then add a file upload form to the controller and when the data goes to the model to be saved, it will automatically upload the image and put it where it goes.
If you do not want to build your own, here is a very popular behavior that someone has built.
https://github.com/jrbasso/MeioUpload
Or you could try this simple way of doing it (check the readme.md file) :
https://github.com/malikov/cakephp2.0-image-upload

How to load an image with unique names from a private folder?

I am working on an app for iPad where I want to have lets say 100 jpg's in a folder.
They could be named like 01.jpg, 02.jpg etc.
In my app I like to browse those images and when clicking on one of them I need the name of the image to be able to send some data over the network (the data part works fine).
I tried to use UIImagePicker but I found out there are no name connected to the actual image.
Then I made another approach where I have a number of pages where I have buttons and here I load in the images which works fine as long the are a part of the recourse of the project...
But here comes the real problem.
The user of the app should be able to change those images over time without recompiling the app.
So I do look for a way to have a folder where the user can place/replace images with the names 01.jpg etc and the app to use those updated images.
Ideas are very welcome.
Wiljan
I am not sure that I understand what you mean, but You can save images in your application documents folder. You can find more details at:
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/StandardBehaviors/StandardBehaviors.html#//apple_ref/doc/uid/TP40007072-CH4-SW6
You can also use NSFileManager to copy files.
what I suggest to do is :
put default images on project resources.
At first start, copy files to documents folder.
always use images from documents folder.

How can i convert WriteableBitmap to jpg or some other common format?

I have one application that allows user to do various things like rotating and scaling an image and finally when the user clicks on save, the image should get saved on the server. Everything works out fine but the problem is since I am directly saving the WriteableBitmap after converting it to bytearray using WriteableBitmapEx, the saved image is also WriteableBitmap and so I am not able to view it using common Picture Viewer.
I want my image to be saved as a JPEG. How can I do this?
Hey Ankit, here is a sample by John Papa that shows how to save WriteableBitmaps to PNG's.
http://johnpapa.net/silverlight/saving-snapshots-to-png-in-silverlight-4-and-the-webcam/
He uses two options: http://imagetools.codeplex.com/
And: http://blogs.msdn.com/b/jstegman/archive/2008/04/21/dynamic-image-generation-in-silverlight.aspx
I would suggest the ImageTools route.