android-canvas

SurfaceView shows black screen - Android

微笑、不失礼 提交于 2019-11-28 03:24:58
问题 Basically I want to use SurfaceView for animation. Therefore the class implements Runnable. To experiment, I want to draw a circle. However, it shows only a black screen. I have been trying for days. Really appreciate if someone can help. MainActivity class public class MainActivity extends Activity { private Bitmap Liquid; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature (Window.FEATURE_NO_TITLE); getWindow().setFlags

How to show both MarkerIcon and Title in google map as like Google Apps?

六眼飞鱼酱① 提交于 2019-11-28 03:18:35
问题 When I find nearest restaurants in Google's Maps Android Application the restaurant name is showing near to marker icon as default. (Refer Google Image). But in my application I need to do same when I search for nearest restaurants, I able to display only marker icons. (Refer My Application Image). Google Image: My Application Image: Partial Solution : Here I found partial solution for this we get this by drawing a text using canvas. I used below code refer by these links here and here But

Capture image using dynamic co-ordinates through the camera

血红的双手。 提交于 2019-11-28 02:09:55
问题 I am making a camera based application, where I put a rectangular view over the camera. When I capture an image using new Camera.PictureCallback() , I cropped that image so as it will get the part of the rectangle. Well, its working fine. Now I implemented View.OnTouchListener and using that I made the shape movable. So, I need to capture the image with the final selection of the user, like where they place the rectangle. Bitmap imageOriginal = BitmapFactory.decodeByteArray(data, 0, data

How to Clip a Star in android ? But the appearance of the star is clear

南楼画角 提交于 2019-11-27 23:20:12
First to see the below images. package com.syncfusion.rating; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Region; import android.view.View; /** * Created by chozarajan.pandiyarajan on 10/9/2015. */ public class SfRatingItem extends View { private int fillColor,minDim,topXPoint,topYPoint; private double bigHypot,bigA,bigB,littleHypot,littleA,littleB,value; private Paint starPaint; private Path path; public SfRatingItem(Context context) { super(context);

Android TextureView hardware acceleration with lockCanvas()

≯℡__Kan透↙ 提交于 2019-11-27 22:52:53
I'm trying to use the hardware acceleration for Android with my canvas. I used to have a SurfaceView which I did lockCanvas() on to get a canvas which I later draw on, but I changed to TextureView since I couldn't get SurfaceView to use hardware acceleration. I'm currently trying to get this canvas to use hardware acceleration. Canvas canvas = this.lockCanvas(); System.out.println(this.isHardwareAccelerated() + ", " + canvas.isHardwareAccelerated()); Gives me the output: true, false ( this is a TextureView ) Does anyone know why the canvas is not hardware accelerated, and how to make it so?

Android: Enable Scrollbars on Canvas-Based View

亡梦爱人 提交于 2019-11-27 22:38:33
I have a custom view that extends View. It displays drawn shapes, and allows the user to add to those drawings via drawing touch events to the View via onDraw. I've enabled the ScaleGestureDetector so that the user can zoom in on a particular section and draw, but as I am using single-touch to draw, they cannot use their finger to pan around the zoomed in View. I've tried to enable scrollbars for the View such that when they are zoomed in, the scrollbars are displayed and can be used by the user to pan... but I simply can't get the scrollbars to be displayed. Essentially, what I am doing is to

Taking Screenshot

♀尐吖头ヾ 提交于 2019-11-27 20:51:13
I'm developing an application for taking screenshots in the device. In this application, we can draw anything on the screen. For this I am using Canvas, Paint and Path to do this. I'm using this code to take screenshots: public void saveScreenshot() { if (ensureSDCardAccess()) { Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); onDraw(canvas); File file = new File(mScreenshotPath + "/" + System.currentTimeMillis() + ".jpg"); FileOutputStream fos; try { fos = new FileOutputStream(file); bitmap.compress(Bitmap

Loading a resource to a mutable bitmap

浪尽此生 提交于 2019-11-27 20:05:42
I am loading a bitmap from a resource like so: Bitmap mBackground = BitmapFactory.decodeResource(res,R.drawable.image); What I want to do is make some changes to the bitmap before It gets drawn to the main canvas in my draw method (As it would seem wasteful to repeat lots of drawing in my main loop when it isn't going to change). I am making the changes to the bitmap with the following: Canvas c = new Canvas(mBackground); c.drawARGB(...); // etc So naturally I get an exception java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor So to avoid that I made a copy of the

How to Save The Image From Canvas code in Android Application?

一世执手 提交于 2019-11-27 19:04:25
问题 I have created a image in OnDraw(Canvas),i tried to Save that Image But its Not Working.image is Saved with Zero size. Here my coding private int w; private int h; @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { this.w = w; this.h = h; super.onSizeChanged(w, h, oldw, oldh); } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub Bitmap toDisk = Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888); canvas.setBitmap(toDisk); Paint paint = new

How to set gradient style to paint object?

邮差的信 提交于 2019-11-27 18:19:34
The code for drawing an arrow with Style: Fill is given below: paint.setColor(Color.parseColor("#bdc0dc")); paint.setStyle(Style.FILL); canvas.drawPath(arrowPath, paint); paint.setColor(Color.BLACK); paint.setStyle(Style.STROKE); paint.setStrokeWidth(2); canvas.drawPath(arrowPath, paint); And the output I obtain is this : Now what I want do is set style to Gradient(Style.gradient not present in android...) to obtain the arrow similar to the image given below : How do i do it ? I tried adding style in style.xml but was unable to add gradient there as it accepts item as parameter.. use the code