android-canvas

Clear bitmap & canvas

情到浓时终转凉″ 提交于 2019-12-11 20:35:47
问题 Anybody have an idea how to clear a Bitmap and Canvas? I think somewere is wrong or incomplete code. For example on FirstActivity.java at public void forceRedraw() I recive a message to create a method on invalidate(). If you need another class just tell me. I really don't know where can be my mistake. I am using the following code. It is little large but hope to understand it. this is my FirstActivity.java public class FirstActivity extends Activity implements ColorPickerDialog

convert from hex to decimal Arduino

拜拜、爱过 提交于 2019-12-11 18:41:17
问题 I am extracting the weight of a Reach Stacker , for the moment this is my result : get data from ID: 18FFF227 2 1 F0 3C 0 0 1 0 what I need is to take F0 3C 0 0 and change it to 0 0 3C F0 then convert it to number to decimal. 003CF0 = 15600 according to this page: enter link description here this would be my number in decimal 15600 this my code : #include <SPI.h> #include "mcp_can.h" #include <SoftwareSerial.h> SoftwareSerial mySerial (3,2); // the cs pin of the version after v1.1 is default

Sending text from fragment to custom view where I want to use canvas.drawText [duplicate]

浪子不回头ぞ 提交于 2019-12-11 18:27:04
问题 This question already has an answer here : Supplying text from fragment to custom TextView (1 answer) Closed 6 years ago . I am new to Android and want to pass some text from a fragment to a custom view. Inside the custom view I want to use canvas.drawText to position the string. The reason I want to use canvas.drawText is for consistency with the position of some graphics. What is the procedure for this? Just to clarify, my fragment has something like this: public class Fragment1 extends

Android - Trying to gradually fill a circle bottom to top

无人久伴 提交于 2019-12-11 17:33:11
问题 I'm trying to fill a round circle (transparent other than the outline of the circle) in an ImageView. I have the code working: public void setPercentage(int p) { if (this.percentage != p ) { this.percentage = p; this.invalidate(); } } @Override public void onDraw(Canvas canvas) { Canvas tempCanvas; Paint paint; Bitmap bmCircle = null; if (this.getWidth() == 0 || this.getHeight() == 0 ) return ; // nothing to do mergedLayersBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap

Drawing custom shape onto Canvas in Android

不羁的心 提交于 2019-12-11 17:28:43
问题 I've been stumped by this one for a little bit, so I figured I'd ask here to see if anyone has any pointers. In a nutshell, I have an app where I want multiple complex shapes to be drawn onto a canvas, which will then be drawn onto the screen (I'll be implementing panning around the large canvas as suggested in this question's answer: Android: Drawing and rotating on a canvas) How exactly do I go about creating a custom shape and drawing it at arbitrary locations/rotations on a Canvas in

Flutter CustomPainter canvas rotate pivot

允我心安 提交于 2019-12-11 17:28:02
问题 In my Android Studio project, I rotate the canvas simply as following canvas.rotate(angle, cx, cy); with cx and cy the center of the screen (i.e. the pivot). But in Flutter, there's only a single rotate method: canvas.rotate(double radians) and as you can see, when I tested the pivot it uses by drawing some rectangles and rotating it and it uses top-left as pivot point. Is there a way to instruct Flutter to use my own provided pivot point? 回答1: canvas.translate(cx, cy); canvas.rotate(angle);

android: clean my view when I click button

江枫思渺然 提交于 2019-12-11 17:16:32
问题 I create a view and use canvas drawing something. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyViewCircle myViewCircle = new MyViewCircle(this); setContentView(R.layout.main); Button evolve = (Button) findViewById(R.id.evolve); img01.addView(myViewCircle); evolve.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub } }); } private class MyViewCircle extends View { public

how to draw lines with drawLine method in multiple density screens

纵饮孤独 提交于 2019-12-11 16:33:29
问题 I have read many posts about my problem but I haven't found a solution. I'm going crazy! I use the following code, in the main Class, to get the pulse on the screen: public boolean onTouchEvent(MotionEvent event) { x = (int) event.getX(); y = (int) event.getY(); case MotionEvent.ACTION_MOVE: view.draw(canvas); view.invalidate(); break; } view is: DrawView view; and DrawView is an inner class: public class DrawView extends LinearLayout and in the DrawView class I have the next two methods to

Android SurfaceView displays blank when locked canvas is not null

感情迁移 提交于 2019-12-11 15:18:33
问题 I'm creating a simple game using a view which extends a SurfaceView and using a thread to draw images on the SurfaceView. The game will have its own thread (game engine) to draw and update drawables. I have 3 classes to achieve this, namely BattleActivity, BattleView, and BattleThread. The BattleActivity is called from another activity. BattleThread will call BattleView.update() and BattleView.render() to do the job. But I don't see anything working. I know it all is reachable through logging

replacing one bitmap with second one canvas android

空扰寡人 提交于 2019-12-11 15:09:56
问题 i want to make an application in that there is two bitmap, i want to remove image whenever i touch my finger or move my finger and second bitmap's part be shown will be shown & first image's part will be erased i have used following code but in that both images are replacing but i want to erase only first one, second will shown on erased area, ..can any body help me how to handle this below is the code public class PaintView extends View implements OnTouchListener { private static final