graphics

JFrame not painting rectangle

谁说我不能喝 提交于 2019-12-12 04:43:04
问题 Have a very simple issue which I haven't come across before. I used a similar layout before when doing a project. import javax.swing.*; import java.awt.*; import java.awt.event.*; class q1 { public static void main (String Args []) { q1Window showMe = new q1Window(); } } class q1Window { q1Window() { JFrame window = new JFrame("Tutorial 1"); window.setSize(600,600); window.setVisible(true); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void paint (Graphics back) { back

Unable to access buffer data after screen capture

折月煮酒 提交于 2019-12-12 04:42:58
问题 We are trying to develop a solution where a Desktop screen from a Windows XP machine needs to be monitored remotely. From our experience, we have identified that GDI based approach is faster than that of DirectX front buffer capture. In GDI we are getting the handle to the screen as follows. // Get the Desktop windows handle and device context hDesktopWnd=GetDesktopWindow(); hDesktopDC=GetDC(hDesktopWnd); // Get the handle to the existing DC and create a bitmap file object HDC hBmpFileDC

Getting a string index based on a pixel offset

∥☆過路亽.° 提交于 2019-12-12 04:39:26
问题 I am custom drawing a text box and now I am implementing the part where the user can click on a line and have the cursor move to where he clicked. I know how to get the row of text he clicked on because the character height is constant across all fonts, but not the column, because I'm not sure how to say "get me all the text that can be drawn before this amount of pixels," and because character width is not consistent unless you're using a fixed-width font, which is not a guarantee. So I have

Binding scattered/overlapping images to a WPF Canvas

筅森魡賤 提交于 2019-12-12 04:30:04
问题 I am porting a GDI application over to WPF, where I displayed several dozen images onto Form, then drew polygons, circles, rectangles, etc over the top of these images using GDI Pens and Brushes. I'm starting to get the hang of WPF binding and would like to store all of these images and markup graphics in my ViewModel. My VM contains an ObservableCollection of my custom DrawingEntitys, DrawingEntity contains DependencyProperties for BitmapSource, Height, Width, CanvasTopLeftY, and

How can I make my cursor synced with the control point during a resize?

蓝咒 提交于 2019-12-12 04:19:36
问题 I am creating an editor. I would like the basic functions on my objects which are rotate/resize and translate . I've managed to do the three of them but the only problem is now my mouse position doesn't follow the control points (the problem gets even worst for the other control points not shown below).. You'll find below an example for the right middle resize with a rotation angle of 30 degrees with no mouseY position, note that the mouse follows perfectly my control point when the rotation

Android - Remove lines from path

人走茶凉 提交于 2019-12-12 04:08:34
问题 I need to make a realtime visual plot of some data much like the "heart beat" scope. Currently, I have data that comes in and I append a Path using lineTo(int, int) . When the plot gets to the edge of the screen, I would like to either shift the data to the left to make room for the new data (preferred) or jump back to the left side of the screen and start erasing the beginning of the path with the new data. I can get the data to move to the left using the offset(int, int) method, but as a

Saving Python turtle graphics as an animated .gif?

别来无恙 提交于 2019-12-12 03:54:29
问题 I have made several programs in Python that have output showing up as a window called Python Turtle Graphics. I want to save these files as .gifs for internet purposes. Can the output of a Python program using the turtle library be saved as an animated .gif? 回答1: The easiest way would be a screen recording app. Something like GifCam could be a nice easy solution. Alternatively you could use something like BB Flashback recorder to record a video and then convert to a gif. The advantage here

Key Listener not working when being pressed

放肆的年华 提交于 2019-12-12 03:48:40
问题 I'm having a lot of trouble trying to make my code move a player (Ship) around a screen. I can get the planets to draw on the screen and the the player ship but I can not figure out how to implement the keyListener to at least print out something. Thank you in advance for all the help! import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Canvas; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Point; import java.awt.Toolkit; import

Android FingerPaint Sample Draws Four Lines

牧云@^-^@ 提交于 2019-12-12 03:48:17
问题 I am trying to follow the code for the FingerPaint example provided in Android's APIDemos sample project. In my case (unless this is supposed to happen), four mirrored lines are being drawn, instead of one line under the user's finger , which is what I want. I have not made any changes to the code: package com.example.android.apis.graphics; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import

How to successfully draw background JPanel once and update foreground JPanel constantly?

天涯浪子 提交于 2019-12-12 03:47:38
问题 I have a custom JLayeredPane, and I am repainting it in my game loop. There are two custom JPanels added into the JLayeredPane. These are foreground and background JPanels. How do I successfully only draw my background JPanel once, (And repaint when window is re-sized or any other reason) to reduce impact on system resources, while continuing to update my foreground JPanel constantly. To re-iterate, I dont want to constantly repaint the background JPanel in a loop. I want to repaint it only