Android: Canvas.draw not drawing on the edge of canvas - view

For whatever reason, my tablet just WILL NOT draw on the horizontal edges of the Canvas as seen in the image below
Which is kinda a bummer as I need full screen access, if I try to draw on the edge it just pushes it out.
TouchDraw.java: http://pastebin.com/0cJf75bF
activity_touch_draw: http://pastebin.com/dRVHfGN4

I solve my problem same as your
you can add following code
try following:
imageView .setImageMatrix (matrix);
imageView .setScaleType(ImageView.ScaleType.MATRIX);

Related

Mask UI Image/RawImage

I recently encountered a problem with UI. I opened a new 2D project and created a canvas with a GameObject with a Image component. I then added a sprite by right-clicking Assets > Create > Sprites > Circle. This added a circle sprite to my Assets folder.
The problem is when I choose the Source Image for the Image component as the circle, it still displays as a rectangle.
The circle sprite is imported as Sprite for Texture Type.
This problem also happens with the other shapes, such as triangle.
I am using Unity 5.6.0b9 Personal. Build target is PC, Mac, Linux Standalone.
I am probably missing something very simple. Any help is appreciated!
It doesn't work like that. Circle and all other type of Sprites under the Assets > Create > Sprites Menu are only made to work with SpriteRenderers. This would have worked if you used SpriteRenderer from GameObject--> 2D Object--> Sprite. They do not work with the UI.
For the UI, this has to be done with the Mask component. Just get any round image then use it to cut out circle from your target square image.
Create a UI Image called "TargetSquare" which is the image you want to round.
Duplicate it then name this "MaskCircle" and then resize it to make it smaller than the "TargetSquare" until that circle shape is what you want.
Make the "MaskCircle" object to be the parent of the "TargetSquare" object then use this round Sprite I made as it's source image.
Attach the Mask component to the "MaskCircle" object.
Done. Your "TargetSquare" object will have the shape of the "MaskCircle" object.
If you get jagged edges, select the sprite you used for the "MaskCircle" image and then make sure that Mipmap is disabled.
Maybe it is bug, in unity 5.6.1f1 same story.
Just try to download new version unity 5.6.2f. I dont know, that bug is fixed or not.
Or
Use some image editor, for example photoshop.
P.S. My fail, all ok, it works on SpriteRenderer component. Unity generates white square, and in this sprite properties setting Sprite Mode to Polygon and creates some shape using vertices.

Jagged edge Image on rotating with Evas map

I am making a watch application for Samsung Gear S2 with EFL Native application.
Problem was happened when I rotate hands of the watch.
Look at following image.
This is normal image I paste it to evas_object and it's not rotated yet.
After I rotate it, the edge of hands has changed to jagged shape like it.
Resolution of gear s2 is 360px X 360px so I make every image is fit to this size.
And I rotate image with following code.
Evas_Map *m = NULL;
m = evas_map_new(4);
//evas_map_smooth_set(m, true);
evas_map_util_points_populate_from_object(m, obj);
evas_map_util_rotate(m, degree, cx, cy);
evas_object_map_set(obj, m);
evas_object_map_enable_set(obj, EINA_TRUE);
evas_map_free(m);
I was try fix it with evas_map_smooth_set() function.
EFL document is written to this setting makes image to "SMOOTH"
and default setting is "true". but I worried tizen change it to "false".
But jagged shape is still showing Despite after I set true or false.
The Watchface that created by "Gear Watch Designer" has not jagged image on rotating there hands.
How I can rotate Image without jagged edge?
OK finally I found why jagged edge is appear on rotating.
In the emulator or my gear s2, default EFL rendering engine is not opengl backend.
So I can fix it with following codes.
elm_config_accel_preference_set("opengl");
Write this code before create window (elm_win_add) it will make anti-aliased image on rotating image.
Sorry for the very late answer, but I believe you can fix this issue in two ways:
Call evas_object_anti_alias_set() on the evas object that is mapped.
As you've mentionned in another answer, use GL acceleration but you may even want to enable MSAA on the backbuffer: elm_config_accel_preference_set("opengl:msaa");

wxToolBar changing device coordinates

Using the mouse I am drawing 2D shapes on the client area of a MDIChildFrame. Recently I have added a wxToolBar to the frame and when I now draw a shape on the client area it seems that the points have shifted by the size the toolbar. Imagine that with mouse I am clicking on (100,100) and drawing a line to (150,150); however, the line appears somewhere (75,75) to (125,125). By the way, wxMouseEvent GetPosition(); reports (100,100) to me.
Removing the toolbar fixes the problem however, I want to keep the toolbar for ease of tool selection.
I use the code:
m_ToolBar=new wxToolBar(this, wxID_ANY);
m_ToolBar->AddTool() //
m_ToolBar->Realize();
this->SetToolBar(m_ToolBar);
Any ideas will be appreciated.
You can always use wxWindow::GetClientAreaOrigin() to manually offset the coordinates by the toolbar height but normally this shouldn't be necessary, and if this doesn't happen with a "normal" frame but only happens with wxMDIChildFrame it would be a bug in wxWidgets that should be reported as usual.
It's also recommended to not draw over wxFrame itself but rather put a wxWindow into it and draw on it. This should also take care of your problem.

How to pan a zoomed out UIImageView inside an UIScrollView?

I have an UIScrollView which contains one UIImageView. Everything is working correctly, I can zoom in and out, when zoomed in I can pan around, etc.
The problem that I am unable to solve is how to pan a zoomed out image around the screen. The user needs to be able to zoom the image out until it's small, and then move that small image to any point on the screen. Sadly, it's stuck in the center of the screen (usually, it would be stuck in the top left corner but I did fix that problem).
There are a couple of things you need to do here. I suggest doing them in viewWillAppear rather than viewDidLoad because if you're using storyboards, it doesn't work quite right in viewDidLoad.
First, you need to set the content size property of your scroll view to be the size of the photo itself because you want the entire area of your photo to be scrollable.
self.scrollView.contentSize=self.photoShown.size;
photoShown is UIImage. scrollView is a UIScrollView
Second, you need to set the frame of your UIImageView that houses your image to be the size of your image:
self.imageView.frame=CGRectMake(0,0, self.photoShown.size.width, self.photoShown.size.height);
if you haven't done this, then the frame of the UIImageView is the size of the screen itself and there is simply nowhere to pan. That's why it needs to be bigger, so you can pan to the regions not currently shown on screen.

Drawing on CATiledLayer or CALayer with pdf in iOS

i have a scrollview which contains a pdfpage rendered with CATiledLayer, i want to draw stuff onto the pdf page so i created a overlay layer, i need the graphic to look vectorized so i decided to use CATiledlayer for the overlay layer. Only problem is that it is very slow to draw (I'm using beizerpath to draw), then i tried to optimize it by creating the overlay layer with the visible height and width when zooming in and out, so i don't need to create the overlay for the whole content bound. But still no luck , i want to try CALayer but the draw path just becomes blurry and pixelated, so i'm not sure how i can improve on this. I also tried drawinrect but for some reason it doesn't seem to work.
I suggest not using bezierpath to draw annotations since it requires you to redraw the whole path every time the pen moves. It would be better if you draw only the current line segment using CGContextAddQuadCurveToPoint.
At touchMoved, get the current point and 2 prev points
Using those points, get the area where the line should be drawn
draw at that area in drawRect using setNeedsDisplayAtRect
inside drawRect, go to the end of your path and add your new line using CGContextAddQuadCurveToPoint

Resources