paint

Make certain area of bitmap transparent on touch

删除回忆录丶 提交于 2019-11-26 06:51:05
My idea is to overlap 2 images on top of each other and upon onTouch, the top image should be made transparent on that touched radius, thus exposing the bottom image. This is how I overlay the 2 images: Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig()); Canvas canvas = new Canvas(bmOverlay); canvas.drawBitmap(bmp1, new Matrix(), null); canvas.drawBitmap(bmp2, new Matrix(), null); I have looked into this post and have a Paint like below to make it transparent: mPaint = new Paint(); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); mPaint

Drawing rectangle on a JPanel

白昼怎懂夜的黑 提交于 2019-11-26 05:56:47
问题 I want to draw a recangle on a JPanel. Am able to draw with the following code. public class DrawingColor extends JFrame { public static void main(String[] args) { DrawingColor d = new DrawingColor(); } public DrawingColor() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().add(new MyComponent()); setSize(400,400); setVisible(true); } public class MyComponent extends JComponent { @Override public void paint(Graphics g) { int height = 200; int width = 120; g.setColor(Color.red

Dynamic Graphics Object Painting

半腔热情 提交于 2019-11-26 02:38:51
问题 Trying to figure out the best way to do this (And without crossing any specifics DO NOTs that I don\'t know about). I\'m working on visually displaying a graph (Various nodes, with edges connecting them) with circles and lines to represent such. Each node will be added during runtime and I can\'t hardcode this. From what I understand, all painting needs to be done in the paint(Graphics g) method - which isn\'t that helpful, since I can\'t be change the parameters and it seems this is only

PictureBox PaintEvent with other method

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 01:29:15
问题 There is only one picturebox in my form and I want to drawcircle with a method on this picturebox but I cant do that and not working.The method is: private Bitmap Circle() { Bitmap bmp; Graphics gfx; SolidBrush firca_dis=new SolidBrush(Color.FromArgb(192,0,192)); bmp = new Bitmap(40, 40); gfx = Graphics.FromImage(bmp); gfx.FillRectangle(firca_dis, 0, 0, 40, 40); return bmp; } Picturebox private void pictureBox2_Paint(object sender, PaintEventArgs e) { Graphics gfx= Graphics.FromImage(Circle()

Re-paint on translucent frame/panel/component.

和自甴很熟 提交于 2019-11-25 23:42:56
问题 I\'m trying to create a translucent window with Java on OSX and add a JLabel to it. This JLabel changes its text every second.... However the component is not repainting well. How can I solve this problem? I\'ve found the these articles, but I can\'t figure out how to solve it. If possible, please paste the fixing source code, here\'s mine: import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import java.awt.Color; import java.awt.Font; import java.util.Timer;

How do I suspend painting for a control and its children?

人走茶凉 提交于 2019-11-25 22:59:09
问题 I have a control which I have to make large modifications to. I\'d like to completely prevent it from redrawing while I do that - SuspendLayout and ResumeLayout aren\'t enough. How do I suspend painting for a control and its children? 回答1: At my previous job we struggled with getting our rich UI app to paint instantly and smoothly. We were using standard .Net controls, custom controls and devexpress controls. After a lot of googling and reflector usage I came across the WM_SETREDRAW win32