I a working on a simple window phone application. In which I have two filed Name and Images.
I want to save this item and want to view all saved data.
Now My query How to select images to save? and How to save images and also get images to view.
I also used PhotoChooserTask but How to save selected image and how to get saved images?
I know about how to save image file in Isolated storage. But how to save selected images and get all data?
Thanks,
Hitesh.
Thanks for your reply. I knew about photoChooserTask. I also save my image file in isolated storage. But I dont know what is the images path to save images path in database and how to display all those images in datagrid. I have a table which have fields like ID, Name and Image path. I dont know what to save in imagepath filed if I saved image in isolated storage and how to display all data in datagrid.I used following code to save data into database. IN below code please correct the image path if I was wrong.
CategoryVO newCategory = new CategoryVO()
{
Name = txtCategoryName.Text,
ImagePath = txtCategoryName.Text.Trim() + ".jpg"
};
Expdb.Category.InsertOnSubmit(newCategory);
Expdb.SubmitChanges();
Using the PhotoChooserTask you can actually launch the photo chooser application and handle the selected image.
If you want to integrate this in your application, create the instance of the PhotoChooserTask and call the Show() method. If you want to handle the user’s selection, register the Completed event which will give you handle of the chosen photo.
var photoChooserTask = new PhotoChooserTask();
photoChooserTask.Completed += PhotoChooserTaskCompleted;
photoChooserTask.Show();
In the completed event implementation, you can get the chosen image as PhotoResult and set the image to your Image control or can use it in other places.
void PhotoChooserTaskCompleted(object sender, PhotoResult e)
{
switch (e.TaskResult)
{
case TaskResult.OK:
imageChooser.Source = new BitmapImage(new Uri(e.OriginalFileName));
break;
}
}
Source: http://www.codeproject.com/Articles/350126/How-to-use-the-PhotoChooserTask-to-Launch-the-Medi
Related
How I can get the image that the user just uploaded to display in another element on the same page? I'm using the storeAsFile property within the filePond options.
As note, I'm currently displaying the image with ImagePreview plugin within the filepond input instance, but i want to show this image on another part of the page. Hope i'm being clear enough.
Found the solution,
pondPhoto.on('addfile', (error, file) => {
// this object contains the file info
console.log(file.file)
// you can construct a blob object
const imageSrc = URL.createObjectURL(file.file)
// then you may attach it to any image in your DOM
document.querySelector('img').setAttribute('src', imageSrc)
})
Why this does not load the image?
private void OnButtonClickedLoadImage(object sender, EventArgs e)
{
ImageSource imgSrc =
ImageSource.FromFile("C:\\MyApp\\MyPicture.png");
ImageViewerc.Source = imgSrc;
}
If you want to load local images, in Android, Place images in the Resources/drawable directory with Build Action: AndroidResource. In ios, The preferred way to manage and support images since iOS 9 is to use Asset Catalog Image Sets. Then use Asset Catalog Image Sets. The picture name can get the picture.
Thank you all (including Jason) for your help. Based on everyone's comment above, I corrected my code to properly load my image like this:
ImageSource imgSrc = ImageSource.FromResource("MyApp.pic2.png", typeof(ImageResourceExtension).GetTypeInfo().Assembly);
ImageViewerc.Source = imgSrc;
The image must be accessed like this: AppName.ImageFileName.ext (I was missing the AppName
Also I should note that the character case between the actual file name in Solution Explorer and the code-behind MUST MATCH or image won't load.
I'm developing an application where the user can add photos from windows phone 7 photo library and assign them to a particular view. To do this I save the OriginalFileName on the database (LINQ to SQL). Later I want to recover the photo and load it into the view. Do you know what I can do? currently I have this code but does not work.
When the user has selected the picture I keep his name in the variable fileName:
private void photoChooserTask_Completed (object sender, PhotoResult e)
{
BitmapImage image = new BitmapImage ();
e.OriginalFileName = fileName;
image.SetSource (e.ChosenPhoto);
this.Thumbnail.Source = image;
this.Thumbnail.Stretch = Stretch.UniformToFill;
}
Later, when the user wants to save this setting I save the fileName in database.
This is the code when I load the view that must contain the photo.
imgSource var = new BitmapImage (new Uri (picture.Url, UriKind.Absolute));
item.LeftImage.Source = imgSource;
Where picture.Url contains the filename.
Any idea? I saw on the internet that you can keep the whole image, but give it the best possible.
What you should do is save the picture returned from the PhotoChooserTask in the IsolatedStorage.
You will then be able to load it when needed.
Here is how to Read and Save Images.
For what you need is to get the picture by browsing the MediaLibrary without using PhotoChooserTask, because as you experienced, the file name might not be the same if you use different methods.
For the custom MediaLibrary browsing interface, you could refer to this codeplex project:
https://multiphotochooser.codeplex.com/
Using Coldfusion 8 has anyone been able to either embed images into a excel spreadsheet (xlsx) or link them via img src?
Some background info: The cf server will pickup an excel document with product rows. Based on the product id and style etc, I be able to find or create an image that gets added as the first column into the existing excel doc.
I know coldfusion 9 has a function called SpreadsheetAddImage, unfortunately I'm on cf 8 with no chance to upgrade.
I am not sure what you are currently using to manipulate the xlsx files. However, the spreadsheet functionality in CF9 utilizes POI, which can obviously be used from CF8 as well. It just requires a little more low level code.
Pre-requisites:
Though POI is bundled with CF8, it is an old version. You need a newer version to manipulate .xlsx files. You can either use the javaLoader -OR- replace the existing jars in {cf_root}\lib folder. Note, I do not know if replacing the jars has any negative side effects.
Adding Images:
Excel does not really support <img> tags, only hyperlinks. However, you can embed images within the workbook like SpreadsheetAddImage does. As outlined in the POI's Busy Developers Guide, the basic process is:
Load the xlsx file with the WorkBookFactory
Grab the binary of each image and add it to the workbook
Anchor each image to the desired cells
Save the modified workbook to back to disk
Example:
<cfscript>
// ..
// load the xlsx file with the javaLoader
factory = loader.create("org.apache.poi.ss.usermodel.WorkbookFactory");
input = loader.create("java.io.FileInputStream").init( "c:/path/to/someFile.xlsx" );
workbook = factory.create( input );
input.close();
// get the desired sheet and load helper objects (once)
sheet = workbook.getSheet("Your Sheet Name");
patriarch = sheet.createDrawingPatriarch();
helper = workbook.getCreationHelper();
// add the image to the workbook
imageBytes = fileReadBinary( "c:/path/to/someImage.jpg" );
imageIndex = workbook.addPicture( imageBytes, workbook.PICTURE_TYPE_JPEG );
// anchor the picture to the first cell ie A1
anchor = helper.createClientAnchor();
anchor.setRow1( javacast("int", 0) ); // row of first cell (zero based)
anchor.setCol1( javacast("int", 0) ); // column of first cell (zero based)
picture = patriarch.createPicture( anchor, imageIndex );
picture.resize(); // only supported for jpg and png
// save it back to disk
outstream = loader.create("java.io.FileOutputStream").init( "c:/path/to/outFile.xlsx"" );
workbook.write( outstream );
outstream.flush();
outstream.close();
</cfscript>
New Columns
Ironically, inserting a new column is trickier than adding an image. Last I checked, POI still lacked a built in function for inserting new columns. So you would need to shift all existing cells to the right before inserting the images into the first column. The tricky part is maintaining cell formats, merged cells, etcetera.
Is it possible to use System.Drawing.Image in an RDLC Image Control?
All I have been reading were 3 methods:
database
embeded resource
external file
Thank you thank you.
EDIT:
Following up from this .NET or C# library for CGM (Computer Graphics Metafile) format? I now got the image in System.Drawing.Image format and want to display it as part of the report (as an image) --- that's what I want to do.
Not sure if this is what you are looking for, but if you have an image in code and you want to show it in the report, create a wrapper object that has a property that returns the image as a byte array and give then an instance of this wrapper-class with the valid image to the report as a ReportDataSource.
Something like:
ReportDataSource logoDataSource = new ReportDataSource();
logoDataSource.Name = "LogoDS";
logoDataSource.Value = new List<LogoWrapper>() { yourLogoWrapper };
localReport.DataSources.Add(logoDS);
In the report you then you can the image as it were from the database
=First(Fields!LogoByteArrayProperty.Value, "LogoDS")
The wrapper looks something like:
class LogoWrapper{
...
public byte[] LogoByteArrayProperty{
get{
// Return here the image data
}
}
}
I use this quite often. It has the advantage that I don't have to add the image to the db or add it as a resource of every report. And furthermore, the app can say which image should be used.
Please note, the given image format must be known from the rdlc-engine.
The last question would be, how to convert a system.drawing.image to a byte array. I work with WPF and therefore, I dont known. But I'm sure google will respond to this question very reliable.
You Can use the 'Database' Source Option along with Parameters to Dynamically set Image Source from Byte Arrays.
Code Behind:
var param2 = new ReportParameter()
{
Name = "CompanyLogo",
Values = { Convert.ToBase64String(*ByteArrayImageObject*) }
};
ReportViewer1.LocalReport.SetParameters(param2);
rdlc File:
1- Add Text Parameters 'CompanyLogo' and 'MIMEType'
2- Set the Value Property of the Image to =System.Convert.FromBase64String(Parameters!CompanyLogo.Value)
3- Set MIME Type Property to
=Parameters!MIMEType.Value
4- Use 'Database' As Source
How can I render a PNG image (as a memory stream) onto a .NET ReportViewer report surface
i am not quite sure what do you want to do with this but in general it is not possible.Image Control is just a image holder in the RDLC files.These 3 options specify the location from where the image control takes the image which to display from- database, embeded resource or external file. If you give me more info on what do you want to achieve i can give you some kind of solution.
Best Regards,
Iordan