paint

Make certain area of bitmap transparent on touch

十年热恋 提交于 2019-12-17 00:47:52
问题 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

Drawing a rectangle that won't disappear in next paint

女生的网名这么多〃 提交于 2019-12-16 22:53:43
问题 I trying to create a JPanel that draws rectangles. The Panel needs to draw alot of rectangles, but they dont move. One solution to my problem was to create an list with all the rectangles i already created and draw they all in every call of "Paint". But there is a lot of rectangles and it slows the computer. I also tried to use repaint(x, y, height, width) to rapaint just the space of the new rectangle but it did not work. (JPanel keeps erasing previous rectangles.) In sort, i need to draw

How to paint specific coordinates of one JPanel onto another JPanel

99封情书 提交于 2019-12-14 04:08:58
问题 This is my problem : I have one JPanel and i paint in this panel one rectangle ex. 100x100. In another JPanel I wouldlike show/paint fragments on first JPanel ex. 50x50, but if I change first JPanel, another JPanel change too (dont copy graphics or Panel) What I can do this? First Panel Second Panel Public class Okienko extends JFrame { Panel p = new Panel(); public Okienko(){ //setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(p); pack(); setVisible(true); } private class

Java Code for Simple Animation only runs on Windows

核能气质少年 提交于 2019-12-14 03:56:24
问题 In this simple code example for an animation of a bouncing ball: import javax.swing.JApplet; import javax.swing.JFrame; import java.awt.*; public class GraphicsMovement extends JApplet { public static void pause() { try { Thread.sleep(10); } catch(InterruptedException e) { } } public static void main(String args[]) { JApplet example = new GraphicsMovement(); JFrame frame = new JFrame("Movement"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(example); frame.setSize(new

Code is producing a gray screen

纵饮孤独 提交于 2019-12-14 03:50:05
问题 I can't seem to work out what the problem is here. import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.image.BufferedImage; import javax.swing.JFrame; import javax.swing.JPanel; public class GamePanel extends JPanel implements Runnable, MouseMotionListener { private static final int SCREEN_WIDTH = 640; private static final int

Insert a GIF image into JFrame and make it visible and invisible on demand

感情迁移 提交于 2019-12-14 03:29:05
问题 In my application I am extracting data from a project DB. When I do that I want to signal to user that data extraction is in progress. I want to achieve this by making my current frame view.getFrame2() invisible and making view.getFrame3() visible. Frame 3 will have GIF image with frame titled as "Extraction is in progress". I am able to achieve my target but I am not able to view the image in the frame. It's blank. Below is the code snippet I am using; one class is used for view, another one

JLayeredPane not drawing

僤鯓⒐⒋嵵緔 提交于 2019-12-13 18:14:41
问题 Good day, Hopefully this is a quick kill question. I am writing an application that uses JPanels and JLayeredPane inside a JFrame. On the initial start of my application, one of the panels does not show up until my mouse moves over the area where the panel should be. I even call the validate and repaint methods, but I am still able to display both panels together. Any suggestions? Thank you. Here is my JFrame class (which has the main method) import java.awt.Dimension; import javax.swing

Android Drawing, Erasing and Undoing Action

蹲街弑〆低调 提交于 2019-12-13 16:30:21
问题 Here is the code for Drawing and Undoing but unable to join with Erasing. It is either Drawing + Erasing or Drawing + Undoing but cannot three of these. public class Drawing extends View { private Paint mPaint, mBitmapPaint; private Bitmap mBitmap; private Canvas mCanvas; private Path mPath; private float mX, mY; private static final float TOUCH_TOLERANCE = 4; private int color, size, state; private ArrayList<Path> paths = new ArrayList<Path>(); private ArrayList<Path> undonePaths = new

Workaround for overflow restriction affecting fixed-positioned elements in iOS?

瘦欲@ 提交于 2019-12-13 16:17:31
问题 Edit: The main issue is this: overflow: hidden and overflow: auto affect fixed positioned elements in iOS. So if I have a fixed positioned modal dialog in a component within a scrolling feature of the page, that element is not displayed wherever it exceeds the bounds of its parent. This is really messed up, as it's not how fixed positioning works on any other system. So what's the official response to this? Original post: I have a modal dialog that works fine on desktop and Android, but on

draw an image to gtk.DrawingArea?

不想你离开。 提交于 2019-12-13 15:41:20
问题 I'm writing a PyGtk paint program based on the basic tutorial found here. Is there any way to add an image to the drawing area so that you can still draw over the image? Like a stamp, or an imported photo for example. I've tried adding a gtk.Image() but gtk.DrawingArea object has no attribute add . self.window = gtk.Window((gtk.WINDOW_TOPLEVEL)) self.window.set_title ("Canvas") self.window.set_position(gtk.WIN_POS_CENTER) hbox = gtk.HBox(False, 0) self.window.add(hbox) self.window.set