I am implementing one iphone/Android application using Titanium in which I want to crop the image.Please check below flow which I have implemented.
1)Open Camara
2)Take photo
3)Display photo in the application
4)Crop photo with some area
I have implemented above 3 steps but for croping I am facing issue.I have tried below code for croping.
var file = Titanium.Filesystem.getFile(header1).toBlob();
var cropped = file.imageAsCropped(10, 10, 290, 232);
var croImg = Ti.UI.createImageView({
image: file,
top:0,
left : 0,
width:290,
height:232
});
win1.add(croImg);
But i can't get sucess. IF you give me advice then would be appriciate.
Thanks
Theres another way to do it with a separate imageView smaller than the original images and setting what portion to display. check out this link that gives a good example:
http://developer.appcelerator.com/question/72431/crop-imageview
Related
I have a problem to depict many mini-versions of my InkCanvas. In my app it is possible to write or draw on a InkCanvas. Now I want to depict all created InkCanvas in a GridView.
But with mini versions in this GridView i can not create enough mini versions.
I tested it with 36 mini versions and after I show one and navigate back, the App crashs everytime by rendering the same mini InkCanvas with the error: Insufficient Memory. So I searched an found this post:
Insufficient memory to continue the execution of the program when trying to initialize array of InkCanvas in UWP
I checked the Memory workload:
var AppUsageLevel = MemoryManager.AppMemoryUsageLevel;
var AppMemoryLimit = MemoryManager.AppMemoryUsageLimit;
and the memory has enough free space. (is this a bug?)
So I tried to render a image from my grid with a InkCanvas but the strokes were not rendered and all pictures were empty. ( can I save Memory this way?)
So now my question is:
Can someone tell me how to solve this problem? And what is the best way?
Thank you very much in advance!
Agredo
If you want to preview your drawings, better way is to render them to bitmap and show this bitmaps in grid instead of multiple complex controls InkCanvas is.
Here is some code to render inks to bitmap from another SO Answer:
CanvasDevice device = CanvasDevice.GetSharedDevice();
CanvasRenderTarget renderTarget = new CanvasRenderTarget(device, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight, 96);
using (var ds = renderTarget.CreateDrawingSession())
{
ds.Clear(Colors.White);
ds.DrawInk(inkCanvas.InkPresenter.StrokeContainer.GetStrokes());
}
using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
await renderTarget.SaveAsync(fileStream, CanvasBitmapFileFormat.Jpeg, 1f);
You also need to add Win2D.uwp nuget package to your project.
My requirement is i need to detect human face from the given cctv image. In the cctv image there will be unnecessary objects which need to be removed.if the obtained face image is blur needs to improve the quality as well
currently we are trying with opencv API, the code as follows
CascadeClassifier cascadeClassifier = new
CascadeClassifier("haarcascade_profileface.xml");
Mat image=Highgui.imread("testing.jpg");
MatOfRect bodyDetections = new MatOfRect();
cascadeClassifier.detectMultiScale(image, bodyDetections);
for (Rect rect : bodyDetections.toArray()) {
BufferedImage croppedImage = originalPic.getSubimage(rect.x,
rect.y,rect.width,rect.height); **unable to detect the body coordinates
here**
}
In the above approach multiple objects of the image are detected as face,which is error.
In the cctvc image if there is only side face how to extract the complete face ?
Pls suggest the best possible way to achieve my requirement.
Thanks
IMGen
You may want to look at the new AWS solution
https://aws.amazon.com/blogs/aws/category/amazon-rekognition/
I'm working on a feature in codenameone application, wherein user can capture a photo and save/display it with date,time details on it. Can these details be stored as part of the image? how can I display these details on the image?
You need to use a mutable image and draw the original image on it then draw the date and time/save it.
Image img = Image.create(original.getWidth(), original.getHeight());
Graphics g = img.getGraphics();
g.drawImage(original, 0, 0);
g.setColor(0xffffff);
g.setFont(myFont);
g.drawString(0, 0, todaysDateAndTime);
ImageIO io = ImageIO.getInstance();
io.save(....);
I did the code above from my head so it might have some issues and didn't implement the call to save but the basics should point you in the right direction.
I have an application that displays leave and absences using an Infragistics UltraMonthViewMulti user interface control.
I have several type of absences that have different colours. I have successfully created a draw filter that shows a half day triangle on the appropriate day using the following code.
If (day.Date.CompareTo(DateTime.Today) = 0) Then
drawParams.Graphics.DrawImageUnscaledAndClipped(Image.FromFile("..//..//redTriangleHalfDay.png"), day.Rect)
Return False
End If
The above code requires a PNG file in the appropriate color in the project. I would like to create these colored images dynamically in code and avoid having a large number of PNG files.
Is this possible?
Any help or suggestions greatly appreciated.
James O'Doherty
Maybe another solution for your task (using again DrawFilter) could be if you replace your images with another type of symbols/colors. Instead of drawing images, you could draw triangle, cirlces, lines, arcs and so on, if you are using for example:
Graphics gr = ultraMonthViewMulti1.CreateGraphics;;
gr.DrawPolygon(new Pen(Color.Red), new Point[] { new Point(10, 10), new Point(20, 20), new Point(10, 30), new Point(10, 10) });
By this way (using three points) you could draw a triangle. Also you could use other draw methods. For example:
gr.DrawCurve, gr.DrawEllipse, gr.DrawLine, gr.DrawPie
Feel free to write me if you have any questions
In my app for WP7.5, user can navigate into the university. He can see on the map his initial position acquired by scanning a Qr Code. Map image is Canvas background. Once he chooses the destination whose X and Y coordinates are known, how can I draw on the map the route from user's current location to the destination? I don't know if it is possible.
This is the working code that allows to show user's starting position on the map.
public void MarkLocation(ImageBrush imgmap, int posizioneX, int posizioneY)
{
Canvas.Background = imgmap;
Image imgmarker = new Image();
imgmarker.Source = new BitmapImage(new Uri("Images/marker.png", UriKind.Relative));
Canvas.SetLeft(imgmarker, posizioneX);
Canvas.SetTop(imgmarker, posizioneY);
Canvas.Children.Add(imgmarker);
}
I hope you can help me! Thanks in advance.
If you used the BingMapsDirectionsTask (in WP7) or the MapsDirectionsTask (in WP8) and the user will get a full navigation experience including showing the route and you'll not need to worry about dynamically generating images or overlaying items on a Map control.