android-canvas

Android Development: Combining small tiles/bitmaps into one bitmap

主宰稳场 提交于 2019-12-20 03:09:58
问题 Im trying to get all my small images like grass, water and asphalt and so on, into one bitmap. I have an Array that goes like this: public int Array[]={3, 1, 3, 3, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ,1 ,1, 1, 1 ,1 ,1 ,7 ,7 ,7, 7, 7 ,7, 7 ,7 ,7, 7 ,7 ,7 ,7 ,7, 7 ,7, 7 ,7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7, 7, 7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7 ,7 ,7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7, 7 ,7 ,7, 7 ,6, 6, 6, 6, 6 ,6 ,6, 6, 6 ,6 ,6, 6, 6 ,6, 6, 6 ,6, 6 ,6 ,6 }; So basicly this is a 10*10 Every number is

Can't draw on canvas

橙三吉。 提交于 2019-12-19 12:22:48
问题 I'm developing a paint activity please take a look on the code I'm working on below: public class MyTouchEventView extends LinearLayout { private Paint paint = new Paint(); private Path path = new Path(); private Paint circlePaint = new Paint(); private Path circlePath = new Path(); public Button btnReset; public Button btnSave; public LinearLayout.LayoutParams params; public MyTouchEventView(Context context) { super(context); paint.setAntiAlias(true); paint.setColor(Color.GREEN); paint

Custom Font not working on Android

北城余情 提交于 2019-12-19 11:24:19
问题 I am doing the below. All I get is the basic font, not my custom symbol font. Any ideas? Paint pnt = new Paint(); // SymbolNo is 38. Returns string "&" which is correct in normal font. String symbolText = Character.toString((char)SymbolNo); // Should adopt a symbol font and draw symbol to screen instead. But I just see "&" Typeface tf = Typeface.createFromAsset(m_context.getAssets(), "fonts/myFont.TTF" ); pnt.setTypeface(tf); m_canvas.drawText(symbolText,x, y, pnt); my font is in assets/fonts

ColorPicker in android not working

穿精又带淫゛_ 提交于 2019-12-19 09:48:27
问题 I have made a simple drawing android program for learning ,I have put a colorDialog which is displayed properly bu after selecting any color ,The pen color is not changing ,It still remains "black" the default color.I have tried as below,Please help me for it,My code is as below: Main.java package com.example.singletouch; import java.util.AbstractMap; import java.util.Map; import java.util.concurrent.ConcurrentLinkedQueue; import com.example.singletouch.SingleTouchView.DrawingPens; import

Understanding Android Canvas Clipping

柔情痞子 提交于 2019-12-19 08:13:34
问题 I am having trouble finding an answer to this. Consider the clipping code below: boolean is_ok = mycanvas.clipRect(clip_left, clip_top, clip_right+1, clip_bottom+1); mycanvas.getClipBounds(clipRect); if (!is_ok || clipRect.left != clip_left || clipRect.top != clip_top || clipRect.right != clip_right+1 || clipRect.bottom != clip_bottom+1) { Log.i("DEBUG", "setClipping failed"); } When the clip bounds are returned they don't match what was just set. For example if clip_left, clip_top, clip

Drawing dotted (…)trail path instead of a line (________)

纵然是瞬间 提交于 2019-12-19 07:51:17
问题 Now below is my code that draws path between geopoints in map. This works perfectly fine. What I'm trying to implement is instead of drawing a line,display this path with the dots(.) as in iPhone. I want it to be like this gp1.........gp2 instead of drawing in a single straight line like gp1_ _ __ _ _gp2. I have tried almost all the options for doing this but still no success on this, any one can help me solving this? private void drawPath(List geoPoints, int color) { List overlays =

Drawing a squircle shape on canvas (Android)

对着背影说爱祢 提交于 2019-12-19 04:08:46
问题 Here is what I'm using to draw a circle shape on to the canvas (and then an icon bitmap on it): private static Bitmap makeIcon(int radius, int color, Bitmap icon) { final Bitmap output = Bitmap.createBitmap(radius, radius, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(output); final Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(color); canvas.drawARGB(0, 0, 0, 0); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) canvas.drawCircle(radius / 2, radius /

Android: Drawing to canvas, way to make bottom left correspond to (0,0)?

不打扰是莪最后的温柔 提交于 2019-12-19 03:09:37
问题 I'm trying to write a graph class I can use in Android(I'm aware pre-made ones exist), but converting all of my coordinates would be a pain. Is there an easy way to make the screen coordinates start at the bottom left? 回答1: No, I don't know of a way to move 0,0 to the bottom left and get what you would typically think of as "normal" coordinates. But combining scale() and translate() might do the trick to achieve the same effect. canvas.translate(0,canvas.getHeight()); // reset where 0,0 is

Add noise effect to a drawing

寵の児 提交于 2019-12-18 18:20:53
问题 I'm in the process of creating a custom view for my android application and would like to add a noise overlay over my drawings. My drawings are pretty standard, arcs, bezier curves, etc. What would be the way to go with creating a noise overlay over arbitrary shapes, drawn with canvas? 回答1: Use a tileable transparent noise png and cover the canvas with it. 来源: https://stackoverflow.com/questions/6994289/add-noise-effect-to-a-drawing

How to draw Bezier Curve in Android

╄→尐↘猪︶ㄣ 提交于 2019-12-18 12:02:26
问题 I have a requirement to create bezier curve in my project. For that purpose I am drawing a view with paint, but the problem is that I am not getting the exact shape for my need as mentioned in the picture below. So kindly help me with your solutions and changes or modifications in my code. Thanks in advance. Code I am using to create Bezier Curve: public class DrawView extends View { public DrawView (Context context) { super (context); } protected void onDraw (Canvas canvas) { super.onDraw