I stumbled upon a problem during my work with codename one and the parse4cn1 plugin.
I try to upload an image which I took with the capture module of codename one. According to the documentation of parse4cn1 I have to convert the image into “Bytes” with the “getBytes” function. But according to the Codename one documentation getBytes only works with Strings and not with images.
Do you know how to “convert” the image appropriately?
I have been using this documentation, the section "uploading files":
https://github.com/sidiabale/parse4cn1/wiki/Usage-Examples#uploading-files
getBytes() is a method of EncodedImage not image. An encoded image can map to a PNG or JPEG and is a subclass of Image. You can use EncodedImage.create*() methods to load an EncodedImage directly or convert an existing image to an EncodedImage:
EncodedImage e = EncodedImage.createFromImage(img, false);
The second argument indicates if this should become a PNG or JPEG. If the image includes transparent/translucent pixels use PNG. If the image is a photo use JPEG.
Related
I am generating tiles from very large images to use with leaflet. I have a working solution that uses System.Drawing.Bitmap and loads the image from file. I already have the image in memory as a BitmapImage however, and would like to reuse it for memory purposes since these images can be very large. But I can not find a good way of doing this with BitmapImage.
What I basically need is something equivalent of
GraphicsHandle.DrawImage(sourceImage, destinationRect, sourceRect, GraphicsUnit.Pixel);
I need to crop and resize a part of the image, and draw this onto another image in a specified location and then save this to file. What is the best way of doing this using BitmapImage?
Can anyone tell me if I can export DXCharts to .xls, .pdf or any kind of vector format?
I am using DXChart from the 2011 v2 release for WPF.
I didn't find anything about this on the web. My fear is that I can't.
Thanks
You can use DXCharts along with XtreReports and a report can be exported to PDF.
Note: I do not know if the resulting chart is then a vector or a bitmap
I also added this question on the DevExpress site: http://www.devexpress.com/Support/Center/p/Q394532.aspx
Finally i got to this conclusions:
The DevExpress charts can be exported to JPG by converting the visual content of the chart to a bitmap and saving it as an image file. They can also be exported to PDF, XLS directly using several techniques which are somewhat poorly documented, but with actual results. The list of techniques is shown below:
- Integrating the DXChart in a DXGrid and exporting the grid (to PDF, HTML, MHT, RTF, XLS, XLSX, CVS, TXT, XPS, BMP, EMF, WMF GIF, JPEG, PNG, TIFF) as shown here http://www.devexpress.com/Products/NET/Controls/WPF/Printing/info.xml. However, the chart will be exported as an image and integrated into the appropriate format file.
- No vector format is available, per se, however the image format files allow for a great dpi resolution, which enables a good resize and zooming behaviour.
public void exportChartToPDF()
{
PrintSizeMode sizeMode = PrintSizeMode.Stretch;
chart3D.ExportToPdf("Output.pdf", sizeMode);
Process.Start("Output.pdf");
}
Have MediaElement in my application used to preview media file such as music, video, image..
MediaElement only allow set source is a URi(contain file path).
I have image storaged by Byte array and now I want preview it on MediaElement.
how to I convert from byte array to uri to preview mediafile ?
If have any other solution to preview mediafie, Please list it. Thank.!
if it is path...then you can use
System.Text.Encoding.UTF8.GetString(byteArray[])
and then assign that path to media element to preview image...
If it is image, you have to convert back that image from byte and then assign it ti Image element...to preview. Check this link:
http://www.codeproject.com/KB/recipes/ImageConverter.aspx
You can do it through a MemoryStream. See example here.
I capture an image using the photo or camera task and I want to resize the image to say example 480x240 from the captured size of around 2592x1944.
how do I do this ?
thanks
You can pass the JPEG stream you get from the Completed event to the PictureDecoder.DecodeJpeg method. The second and the third parameters define the size. You will get a WriteableBitmap that can be manipulated further and saved back to the MediaLibrary. See this blog post for some example.
I am using ImageTool's PNG encoder to create an image.
I have a Grid that contains multiple TextBlocks, each TextBlock contains dynamic text.
When I create a WriteableBitmap from the grid containing the TextBlocks, I then use ImageTool's encoder to convert the WriteableBitmap to a PNG image.
All works well, however, when I view the PNG image (am saving the file to the hard drive for testing purposes) - the text looks slightly blurred. Is this an issue with the encoder or the WriteableBitmap class? And - has anyone experienced this before and are there workarounds?
Thanks.
I'm a part of ImageTool project but I'm playing as a tester since I'm using this library in one of my project... If you can create a sample then you can probably show us so that we can test in our machine.
You can also try with Joe Stegman's encoder or fJCore JPEG encoder.