android-canvas

How to increase scanning area size in zxing

倾然丶 夕夏残阳落幕 提交于 2019-11-27 04:43:10
问题 Hii everyone currently iam working on scanning qr code from my app and i have used zxing library and it's working good and my problem is in my galaxy s4 mobile the scanning area is very small Please help me thanks in advance 回答1: The CameraManager class has two constants defined MIN_FRAME_WIDTH and MIN_FRAME_HEIGHT . You should modify them as desired and everything should work: private static final int MIN_FRAME_WIDTH = 240; // (your desired value here) private static final int MIN_FRAME

Android TextureView hardware acceleration with lockCanvas()

柔情痞子 提交于 2019-11-27 04:36:47
问题 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

Bitmap not drawn anti-aliased

喜欢而已 提交于 2019-11-27 04:21:05
问题 I have a custom View that always draws a Bitmap at a certain rotation. I overwrite the onDraw method, rotate the Canvas and draw the bitmap with an anti-aliased Paint . public RotatedImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); someBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.placeholder); } @Override protected void onDraw(Canvas canvas) { // Save and rotate canvas canvas.save(); canvas.rotate(3F, getWidth() / 2, getHeight

How to use android canvas to draw a Rectangle with only topleft and topright corners round?

随声附和 提交于 2019-11-27 03:52:33
I found a function for rectangles with all 4 corners being round, but I want to have just the top 2 corners round. What can I do? canvas.drawRoundRect(new RectF(0, 100, 100, 300), 6, 6, paint); You can draw that piece by piece using drawLine() and drawArc() functions from the Canvas . Use a path. It has the advantage of working for APIs less than 21 (Arc is also limited thusly, which is why I quad). Which is a problem because not everybody has Lollipop yet. You can however specify a RectF and set the values with that and use arc back to API 1, but then you wouldn't get to use a static (without

Android Canvas change color of intersection of shapes and texts

旧巷老猫 提交于 2019-11-27 03:49:38
问题 I'm trying to change color of intersection of shapes and text using Canvas. i have 2 shapes and 1 text with different paints. This is without any PorterDuffXfermode , and PorterDuffColorFilter mode added to any paint. I want intersection of shapes to be particular color, for example white, and text red or white like the images below. In my example, text is at the bottom, circle middle and rectangle above but it's insignificant, i'm just trying to figure out how it works and how should

How to make a bitmap using canvas clickable?

可紊 提交于 2019-11-27 03:31:22
问题 How do i make the bitmap created clickable? Below is the code which i have used to create a bitmap using canvas. public class DrawView extends View implements OnClickListener { public DrawView(Context context) { super(context); paint = new Paint(); image = BitmapFactory.decodeResource(getResources(), R.drawable.andmrktsmall); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); int canWidth = canvas.getWidth(); int canHeight = canvas.getHeight(); int width = (canWidth -

Android Canvas.drawText

好久不见. 提交于 2019-11-27 03:22:29
I have a view, I'm drawing with the Canvas object in the onDraw(Canvas canvas) method. My code is: Paint paint = new Paint(); paint.setColor(Color.WHITE); paint.setStyle(Style.FILL); canvas.drawPaint(paint); paint.setColor(android.R.color.black); paint.setTextSize(20); canvas.drawText("Some Text", 10, 25, paint); The problem is the text doesn't show through the background, what am I doing wrong? If I remove the canvas.drawPaint(paint) and paint.setColor(android.R.color.black) you can see the text on the screen..... Worked this out, turns out that android.R.color.black is not the same as Color

Android Bitmap/Canvas offset after scale

老子叫甜甜 提交于 2019-11-27 02:32:01
问题 If I have a canvas, on which I draw a Bitmap like this: canvas.drawBitmap(bmLargeImage, srcRect, destRect, paint); and I scale the bitmap: canvas.scale(1.5f, 1.5f, 450, 250); I want to get the position of the Bitmap after the scale. If the position before scale was (0, 0), after scale there is a offset and I need that offset.. how can I get it? Thanks and sorry for the simple question, newbie here... 回答1: Ok lets try to work out the best formula for this canvas.scale(scaleX, scaleY, pivotX,

How to blur some portion of Image in Android?

拈花ヽ惹草 提交于 2019-11-27 02:01:52
I am working in a project where I have to show some portion of the image clear and make rest part of the image blur. The blur should be managed by slider. Means it can be increase or decrease. The final result image should look alike below. During my research for this I found below links useful http://blog.neteril.org/blog/2013/08/12/blurring-images-on-android/ https://github.com/kikoso/android-stackblur http://blog.neteril.org/blog/2013/08/12/blurring-images-on-android/ But the issue in above links is they all make complete image blur. Not some part of image. Kindly suggest some solution to

Canvas not displaying all drawn parts in Custom View?

ε祈祈猫儿з 提交于 2019-11-27 01:30:22
问题 I'm working on a custom view for an android application, similar to the Analog Gauge sample code available from Mind the Robot. Running the code from listed site, I get see this on my screen: (Motorola Droid, 2.2.3), (Emulator, 4.0.3) (Xoom, 4.0.3)(Other phone, 4.0.3) The hand is missing! The drawing calls are being made (I can see them in logcat), but the canvas elements the calls draw are invisible. It's not API level dependent , though; if I import it the right way into a project, it will