android-canvas

Android Canvas OpenGL Renderer is out of memory

纵饮孤独 提交于 2019-12-05 15:27:12
I develop android library for drawing chart at view, using canvas. However, the following errors occur frequently. LogCat: D/NvOsDebugPrintf(11526): NvRmChannelSubmit: NvError_IoctlFailed with error code 12 D/NvOsDebugPrintf(11526): NvRmChannelSubmit failed (err = 196623, SyncPointValue = 94008102) (87 times repeat) D/OpenGLRenderer(11526): GL error from OpenGLRenderer: 0x505 E/OpenGLRenderer(11526): OpenGLRenderer is out of memory! Solution is not found although I am groping for various causes and solution. So, please tell me about what can become a cause which such an error generates? And

How to Move a ShapeDrawable in Canvas on Touch Events

隐身守侯 提交于 2019-12-05 13:28:59
I am trying to implement a Drawing Application in Android. Where the user should be able to select and move the drawn shapes. Currently i have statically drawn some rects and text on my Drawing Canvas: View mDrawingCanvas = new View(mContext) { ShapeDrawable rectangle; @Override public boolean isFocused() { // TODO Auto-generated method stub Log.d(TAG, "View's On focused is called !"); return super.isFocused(); } @Override public boolean onTouchEvent(MotionEvent event) { // TODO Auto-generated method stub return super.onTouchEvent(event); } @Override protected void onDraw(final Canvas canvas)

android use a View from a XML layout to draw a canvas

丶灬走出姿态 提交于 2019-12-05 11:01:22
So basically i want to use a xml layout, but i also want a canvas where i can have graphics performed. What i did was make a view in my xml layout as you can see below. Then in my application i made the view draw the canvas, but it is not working. I'm not sure if my method for solving this is completely wrong or what. So please just take a look at my code and tell me if you see a quick fix or if you have a better method. Thanks in advance I really appreciate it. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

How to draw several lines slowly in constant velocity on canvas by Android?

我们两清 提交于 2019-12-05 10:08:44
I need capture the mark to draw a figure on canvas in Android, and the effect just like the follow gif: Well, as far, I can draw a side with constant velocity by ValueAnimator . However, I just only can draw one side at one time, because I can't save the last side when drawing the next side. So, is there a good way to solve the problem? Code for draw a line slowly by ValueAnimator: GraphicsView.java public class GraphicsView extends View { private int stepX, stepY = 0; private int startX, startY, stopX, stopY = 0; private Paint paint = null; public GraphicsView(Context context) { super(context

Android: Draw a view on canvas

99封情书 提交于 2019-12-05 09:47:11
I have a view inflated, I can draw it on canvas, but can't seem to position it properly. LayoutInflater li = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = li.inflate(R.layout.fix_this_recommendation, null); v.measure(MeasureSpec.getSize(v.getMeasuredWidth()), MeasureSpec.getSize(v.getMeasuredHeight())); v.layout(400, 400, 400, 400); v.draw(canvas); But the view is always at the top left corner. Anyone know why? Each View draws its contents within its own coordinate system, with (0, 0) at the top-left. If you want it to appear elsewhere, you can set a new

Android Drawing Fill Tool

廉价感情. 提交于 2019-12-05 07:57:43
I am making a drawing app for android and I need some help adding a fill tool. I want the tool to flood fill, and to behave like it would in Microsoft Paint, but on a phone. I have a custom view that draws a path on a canvas. I draw different paths for different pens and brushes, and I allow users to pick line thickness and color. When I do: paint.setStyle(Paint.Style.FILL); and I paint, I don't get a fill how I want. I have gotten some suggestions to use the "Flood Fill Algorithm", but I can't figure out how to implement it in my code. Where could I go to see an example of what I am trying to

Draw on a canvas with Bitmap as Background

僤鯓⒐⒋嵵緔 提交于 2019-12-05 07:20:59
问题 I am trying to draw on a picture i have taken. Drawing works without the picture drawn but if i draw the bitmap i only see the bitmap but n drawing comes up. I tried a lot but nothing seems to help. Thanks in advance. private class myView extends View implements OnTouchListener{ File root = Environment.getExternalStorageDirectory(); Path path; ArrayList<Path> _graphics = new ArrayList<Path>(); Bitmap myBitmap; Paint myPaint; public myView(Context context) { super(context); File file = new

Android - Set a view to be on top of items drawn with canvas

跟風遠走 提交于 2019-12-05 07:04:05
I have an android app where the user paints, moves and reshapes some objects over a photo. In this page my screen layout consists of the photo that is loaded and below it (in portrait view) some buttons. My view looks exactly as I want it with the xml below: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/linear" > <LinearLayout android:id="@+id/buttons" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation=

Create alpha gradient on image to create fade effect

元气小坏坏 提交于 2019-12-05 05:29:22
问题 How can I apply an alpha gradient on an image so that it fades linearly? Right now, I'm creating rectangles of unit width and using it to draw the bitmap with a paint object with alpha value being changed in a loop. I only did it since I couldn't think of anything else. So a neater way would be better. Bitmap bitmap = BitmapFactory.decodeStream(is); Bitmap bmp = Bitmap.createScaledBitmap(bitmap, 100, 151, true)); bitmap.recycle(); Rect Rect1 = new Rect(0, 0, 100, 100); Rect Rect2 = new Rect

rotate dial in limited degrees

…衆ロ難τιáo~ 提交于 2019-12-05 03:45:57
All I want rotate image in particular angle as like below image. I have code for rotation but it rotate 360 degree but I want it only for particular degrees and get the selected number which is upper side of dial. below is my code. My custom View this work fine but lake of perfomance. import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PointF; import android.graphics.Rect; import android.util.AttributeSet; import android.util.Log; import android.view