graphics

How to read the RGB value of a given pixel in Python?

三世轮回 提交于 2019-12-17 01:41:05
问题 If I open an image with open("image.jpg") , how can I get the RGB values of a pixel assuming I have the coordinates of the pixel? Then, how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? I would prefer if I didn't have to download any additional libraries. 回答1: It's probably best to use the Python Image Library to do this which I'm afraid is a separate download. The easiest way to do what you want is via the load() method on the Image

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 can I set the 'backend' in matplotlib in Python?

谁说我不能喝 提交于 2019-12-16 22:45:31
问题 I am new user of matplotlib, my platform is Ubuntu 10.04 Python 2.6.5 This is my code import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt plt.plot([1,2,3]) The error is: /usr/local/lib/python2.6/dist-packages/matplotlib/backends/__init__.py:41: UserWarning: Your currently selected backend, 'agg' does not support show(). Please select a GUI backend in your matplotlibrc file ('/usr/local/lib/python2.6/dist-packages/matplotlib/mpl-data/matplotlibrc') or with matplotlib.use()

How do I position one image on top of another in HTML?

ε祈祈猫儿з 提交于 2019-12-16 20:06:23
问题 I'm a beginner at rails programming, attempting to show many images on a page. Some images are to lay on top of others. To make it simple, say I want a blue square, with a red square in the upper right corner of the blue square (but not tight in the corner). I am trying to avoid compositing (with ImageMagick and similar) due to performance issues. I just want to position overlapping images relative to one another. As a more difficult example, imagine an odometer placed inside a larger image.

Breaking an input into words to work on one by one (Java)

一曲冷凌霜 提交于 2019-12-14 04:28:07
问题 I'm trying to implement a java program which, given a string with linebreaks as input through a simple graphical interface, splits it first at lines, then at spaces, and then for each word has an instruction that tells it what to do with it. I got to something like this: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author michelegorini */ import java

surface normal to a cone

流过昼夜 提交于 2019-12-14 04:16:50
问题 Im writing a program in OpenGL/C++ to ray trace a cone.For my intensity calculations I need to know the surface normal.Given a base radius,height and centre coordinates,how do I calculate the surface normal? 回答1: I am supposing that you need to find the normal to the surface given a point on the surface. I am further assuming that this is a cone oriented such that the base is facing down (-y axis) and the point of the cone points up (+y axis). If any of these conditions are not the case, I

How to best display 30+ bpp graphics on a 24 bpp display?

痴心易碎 提交于 2019-12-14 04:16:47
问题 What would be the best way to display the most faithfully graphics that have more than 8 bits per channel on a regular 24 bpp display? 回答1: The best solution I can think of is based on a random dithering that changes every frame. This combines the advantage of dithering with not having a fixed dithering pattern, and since a given pixel changes values many times a second what you perceive is closer to the average of those various values, which is closer to the original "deep color" value than

Making an image fade in and fade out? [closed]

假装没事ソ 提交于 2019-12-14 04:14:30
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . How would I go about making an image fade in and then out? I know an easy way to accomplish this is to just make several images with different opacities. 回答1: Use an AlphaComposite when painting the image: import java.awt.AlphaComposite; import java.awt.Graphics; import java.awt.Graphics2D; import

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

How to save rotated buffered image in another buffered image?

假如想象 提交于 2019-12-14 03:59:53
问题 I am trying to rotate a buffered Image and return the buffered Image (rotated image) using getImage() method. Rotation of image is happening but while saving it save the image as such without rotation of image. Initialization: private BufferedImage transparentImage; PaintComponent: AffineTransform at = new AffineTransform(); at.rotate(Math.toRadians(RotationOfImage.value)); Graphics2D g2d = (Graphics2D) g; g2d.drawImage(transparentImage, at, null); repaint(); A method to return the rotated