android-canvas

Attach canvas drawed line to scene in Android

好久不见. 提交于 2020-01-07 06:41:06
问题 I would like to attach a line drawed with canvas to a Scene. I'm using andengine library. I know that andengine provides line objects that can be draw and attached to a scene, but this is not an option for me because i'm trying to make a pretty glow line. This is how a andengine line is attached to the scene. public class MainActivity extends SimpleBaseGameActivity implements OnClickListener { //--Declaration and implementation of all overrides, etc.-- @Override protected Scene onCreateScene(

Android: SurfaceView Flickering

假如想象 提交于 2020-01-07 03:05:06
问题 I am having an issue with drawing to a SurfaceView , when the bitmap images on the SurfaceView are moved, they flicker (or tear). I did not have this problem in previous iterations of my code. But now that I finally got the bitmaps to scale properly by using a separate Canvas for each bitmap, this problem started occurring. These are the important parts of my custom SurfaceView class: public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback { public DrawingSurface

Android Canvas ScaleFocus causing jumping position

寵の児 提交于 2020-01-06 20:08:59
问题 I am working on a game that will be looking down onto a grid moving pieces around (similar to Chess). I want the user to be able to pan and zoom the map. I have been making transformations to a matrix, and then concatenating those changes to the canvas matrix. While it's mostly working, I have a weird bug: After the initial scale, if I pinch to scale again, the screen jumps (it's as if a swiped somewhere else and it moved there instantly) and then scales smoothly. I have narrowed this

Hide a face of a 3D shape behind another,Android canvas?

怎甘沉沦 提交于 2020-01-06 20:00:43
问题 Suppose that I have to draw two faces of a 3D shape in a canvas.In OpenGL,we use clockwise and non clockwise ordering of vertices to detect what face is front face and what is behind face,but I can not use OpenGL and I would to use canvas.It seems that if we draw behind face and then draw front face,it hides behind face,but my 3D shape rotates and each face some times must be front and some times must be behind. My question is : When shape is rotating,how I can detect witch face is front?Or

Using an ImageView transform matrix instead of canvas.scale(float, float, float, float)

泪湿孤枕 提交于 2020-01-06 13:36:36
问题 I need to change the way I am scaling and moving my imageview to using a matrix instead of calling canvas.scale(,,,,) , but I cannot figure out the proper calls to do this. I had this in my ScaleListener listener class's onScale method public boolean onScale(ScaleGestureDetector detector) { ...//determining zoom level and pivot points offset child.zoom(scaleFactor, zoomCenter[0], zoomCenter[1]); } I had in the child ImageView's onDraw method: protected void onDraw(Canvas canvas){ super.onDraw

Saving canvas drawing to sd card

Deadly 提交于 2020-01-06 12:47:19
问题 I m currently working on canvas drawing in which i hv a canvas with white colored background ( with canvas.drawColor(Color.WHITE); ) and a sketched image of cartoons comics that allows to paint with some colors. The problem is that when i go to save the canvas image only a black screen with color done get saved neither the canvas white background nor the sketched image is appeared.. I m using this code for saving canvas public void saveAsJpg (File f) { String fname = f.getAbsolutePath ();

Canvas - null pointer exception

无人久伴 提交于 2020-01-06 06:41:07
问题 Sometimes, I am getting NullPointerException in the line. Please let me know how to correct this. At the time of error, I have checked the possibility for the null value in variable backgoundImage. The variable backgoundImage is not null. canvas.drawBitmap(backgoundImage, 0, 0 , null); Code: @Override public void run() { // TODO Auto-generated method stub ourHolder = getHolder(); while (isRunning) { if (!ourHolder.getSurface().isValid()){ continue; } canvas = ourHolder.lockCanvas();

Android: Best Way to Programmatically Make an Image and Save it to a Bitmap?

断了今生、忘了曾经 提交于 2020-01-06 05:34:08
问题 I have an app that connects to an external printer device and I need to take some user data and dynamically make an image and print it. The printer API requires a bitmap as input for printing. Note that I never want to draw the programmatically created image to the screen; the generation and printing of the image have no visible UI, it happens in the background. So far I've considered doing it one of the following ways: 1) Make a canvas, never call the draw functions, translate it to a bitmap

Drawing fast in canvas Bitmap android ics

谁都会走 提交于 2020-01-06 04:30:20
问题 I've been developing an app to draw in ics android tablets and i've encountered an issue I can't figure out how to fix. The problem is that I draw correctly and in a real time drawing BUT when I go really really fast (tested on real tablets) the circles are not really circles, they look like pilygons of 5 or 6 sides... Here I declare the bitmap and assign it to the canvas: Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); width = size.x

Android Crop Bitmap Canvas

与世无争的帅哥 提交于 2020-01-06 03:08:35
问题 I want to create the crop bitmap functionality and have referred Android: Free Croping of Image but this sets the bitmap in another imageView.Now I know I can set the cropped bitmap in the canvas but I want to retain the original bitmap and want to do the cropping in onDraw() and not make a different bitmap and then set it in canvas.I have tried to implement the below code in onDraw but there is no cropping and bitmap remains as it is.Pleas help so that I can code this in onDraw() method of