Windows Phone get image source path in String - windows-phone-7.1

I am trying to get image source path in string but not able to get it.
Here is my code
String tempJPEG = imgUpload.Source.ToString() ;
Here imgUpload is <Image x:Name="imgUpload" ></Image>
I am getting this "System.Windows.Media.Imaging.BitmapImage" in tempJPEG.
How can I get image path?

The source property of the image control contains BitmapImage itself. Therefore you need to use the BitmapImage.UriSource property.

Related

Error retrieving image from URL or bad URL with webContentLink

My application is trying to insert a bunch of images to google drive sheet using google app script.
The script method is calling from a Rails app as following:
#app_script.run_script(script_id, request)
The script method is trying to fetch the image through the id and insert it to the sheet.
var srcfile = DriveApp.getFileById(object.image_file_id);
srcfile.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
var image = SpreadsheetApp.openById(object.spreadsheet_id).getSheetByName(object.sheet_name).insertImage(Drive.Files.get(srcfile.getId()).webContentLink, object.column, object.row);
The problem is coming intermittently with the response error from google script:
Exception: Error retrieving image from URL or bad URL: https://drive.google.com/uc?id=1yZULGInEcjQ_nA4j_Nmy6F2e3JcYnLFP&export=download
Note that I can download the image successful if I just copy the link and paste it to browser.
The image file and its parent folder are public share.
It seem hard to detect the problem when it does not always happen.
For those who concern about my script, it is here
Exception: Error retrieving image from URL or bad URL
This is a common error message when the image size is too big.
See here for more information.
You need to recuce the image size - either manually or programmatically - before inserting.
UPDATE
If the suggestion above does not solve your issue, implement the following workaround:
Instead of inserting the image by its webContentLink with the method insertImage(url, column, row) , use the method insertImage(blobSource, column, row):
var image = SpreadsheetApp.SpreadsheetApp.openById(object.spreadsheet_id).getSheetByName(object.sheet_name).insertImage(DriveApp.getFileById(srcfile.getId()).getBlob(), object.column, object.row);
This should solve the issue.

sapui5 UploadCollection - unable to set correct icon

I try to use sap.m.UploadCollection to display attachments. Here is the example from Sap explored:
However, for my documents, I get always this icon:
I checked mimetype is set correctly for the item, filetype is set as well for the uploadcollection.
Do you know where is the trick?
I found the reason:
UploadCollection icon is mapped not to the mimetype specified, but to the filename property. So if the filename is returned without extension, like "Notes" instead of "Notes.txt", then no icon is displayed.
I still do not get why sap wants to parse filename to get extension from it, where mimetype property is 100% suitable for its purpose,
but this is the solution - provide fill filename.

Image class cant read target file

I am trying to read image deep in TEMP folder with Image.read method in order to convert it.
I've seen example like this
I've tried this
InitializeMagick("C:\\Users\\GrayMP\\AppData\\Local\\Temp\\ImageMagick\\Images\\");
Image image;
image.read("result-0.bmp");
and this
InitializeMagick("");
Image image;
image.read("C:\\Users\\GrayMP\\AppData\\Local\\Temp\\ImageMagick\\Images\\result-0.bmp");
, but I catch next exception.what():
app.exe: unable to open image `↑Ё)': Invalid argument # error/blob.c/Op
enBlob/2674
Convertion via ImageMagic works fine, I can do all what I want, but, lib integration doesn't work.
I can't get what I am doing wrong

Can not display local image file as WebEngine image src attribute

I'm trying to set the src of an img tag I have dynamically. The following piece of code works when running from eclipse but not after exporting it as a running jar file:
doc.getElementById("user-thumb").setAttribute("src", selectedVcard.getThumb().getFilePath());
The element got by the "user-thumb" id is an image. The thumb object returned is a simple custom ImageView I've extended to hold more information and is initialized using:
public Thumb(String url) {
super(url);
this.setFilePath(url);
getStyleClass().add("thumb");
}
the method getFilePath() is returning a path from a temporary file starting with:
file:/
But I've already tried to change it to
file://
and even:
file:///
and got no success. I have googled and searched here but every answer points to start with file://. Is there something wrong with my code or is it javafx 2? By the way, I'm using javafx 2.2 GA and the jre 1.7.0.6 from oracle. Cheers
You could use Data URI for the images
Something like ...
String imageMimeType = "image/jpeg"; // Replace this for the correct mime of the image
String dataURI = "data:" + imageMimeType + ";base64," +
javax.xml.bind.DatatypeConverter.printBase64Binary(imageByteArray);

smart gwt beginner- how to draw image in a draw pane with drawImg.setSrc()

I am trying to draw an image within a draw pane. This is the code that I am using--
DrawPane drawPane = (DrawPane) event.getSource();
DrawImage drawImg = new DrawImage();
drawImg.setSrc("/other/cokeclassicsm.png");
//drawImg.setLeft(77);
//drawImg.setTop(50);
drawImg.setDrawPane(drawPane);
drawImg.draw();
But no image is showing on screen--
Now I referred to the Javadoc -- drawImg.setSrc (this link) and it says that the URL to the image has to be specified...Does this mean I cannot specify a relative path at all?
My image is within war/images/other folder...
Have you tried :
DrawImage drawImg = new DrawImage();
// drawImg.setSrc("/other/cokeclassicsm.png");
drawImg.setSrc("other/cokeclassicsm.png");
Starting a path with "/" with send you to the root of the URL. Starting it without "/" says that you want a relative path to where you are in right now.

Resources