graphics

Saving Graphics to Bitmap outside of paint?

筅森魡賤 提交于 2020-01-17 01:21:13
问题 Trying to save a C# Winforms Graphics Object to a bitmap, yet I am getting an ArgumentException with this code outside of the Paint event: public Bitmap Bitmap { get { return new Bitmap(100, 100, this.Graphics); } } Where this.Graphics is just set in the Paint event handler, I'm guessing the object becomes invalid outside of the event, which is annoying as I'd like to avoid having to put code in there for saving the images. Can anyone point me in the right direction? Edit: I will have to re

OpenGL ES as a 2D Platform

被刻印的时光 ゝ 提交于 2020-01-16 18:56:08
问题 I've seen a lot of bandying about what's better, Quartz or OpenGL ES for 2D gaming. Neverminding libraries like Cocos2D, I'm curious if anyone can point to resources that teach using OpenGL ES as a 2D platform. I mean, are we really stating that learning 3D programming is worth a slight speed increase...or can it be learned from a 2D perspective? 回答1: GL is likely to give you better performance, with less CPU usage, battery drain, and so on. 2D drawing with GL is just like 3D drawing with GL,

Manipulating the pixels within a BufferedImage through an Array

一曲冷凌霜 提交于 2020-01-16 13:03:19
问题 I'm currently following a series on Java game development from scratch. I understand most java and oop concepts but have very little experience when dealing with graphics and hardware acceleration. The lines of code that I am questioning are: private BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); private int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); The BufferedImage "image" variable is always the variable being drawn to the

How to tint an image in HTML5

北城以北 提交于 2020-01-16 00:41:12
问题 I want to tint an Image but instead of subtracting colors from the origin, I want to add them. Is there a quick way to do this in HTML5 with javascript? 回答1: Yes there are two simple ways you can use. Method 1 - Composite mode The composite mode lighter is in reality an additive mode. You can activate it with a single line of code ( online demo here ): ctx.globalCompositeOperation = 'lighter'; The next thing drawn will add to what is in the background which gives you this result if you

how to determine a correct domain for a range of numbers for drawing a line-graph?

依然范特西╮ 提交于 2020-01-15 11:43:29
问题 I want to create a line graph but the range of numbers are different sometimes its like : 1,2,5,8,10 and sometimes its like : -5 , -1 , 4 , 5, 15 , 8 ,20 ,... by studying excel and openoffice I understand that they can indicate a range something like : minNumber - k to maxNumber + k and they divide the Y axis into equal area. is there any specific formula for doing these things ? 回答1: When I looked at this problem I found that commercial products do a nice job of extending the range just

how to determine a correct domain for a range of numbers for drawing a line-graph?

非 Y 不嫁゛ 提交于 2020-01-15 11:42:47
问题 I want to create a line graph but the range of numbers are different sometimes its like : 1,2,5,8,10 and sometimes its like : -5 , -1 , 4 , 5, 15 , 8 ,20 ,... by studying excel and openoffice I understand that they can indicate a range something like : minNumber - k to maxNumber + k and they divide the Y axis into equal area. is there any specific formula for doing these things ? 回答1: When I looked at this problem I found that commercial products do a nice job of extending the range just

SSBO hash table, missing values

有些话、适合烂在心里 提交于 2020-01-15 09:24:26
问题 I am trying to run a little data compression experiment. I am trying to compress 3D textures into hash tables to avoid storing empty volume information. To this effect I wrote the hashing function and retreiving function (they are in different shaders): struct Voxel { int filled; ivec4 position; vec4 normal; vec4 color; }; layout(std430, binding = 0) buffer voxel_buffer { uint index; Voxel voxels[]; }; // Data storing shader int a_size = 10000000; void insert(vec3 pos, Voxel value) { ivec3

Java - How to move a rectangle that's drawn by Graphics2D?

爷,独闯天下 提交于 2020-01-15 09:12:15
问题 I'm trying to move a rectangle drawn by Graphics2D over, but it just doesn't work. When I do x += 1; It actually moves it 1 pixel over and stops. if I do say, x += 200; It moves it 200 pixels over ONCE not in every update, but ONCE. public void paint(Graphics g) { super.paint(g); g.setColor(Color.WHITE); g.fillRect(0, 0, this.getWidth(), this.getHeight()); g.setColor(Color.RED); g.fillRect(x, 350, 50, 50); x += 1; } int x is called outside void paint to make sure it's not incremented as 150

How to know if a JFrame is on screen in a multi screen environment

▼魔方 西西 提交于 2020-01-15 08:39:08
问题 My application is used in multi-screen environments. The application stores it's location on close and starts on the last position. I obtain the position by calling frame.getLocation() This gives me a positive value if the frame is on the main screen or it is on the right of the main screen. Frames located on a screen left to the main screen get negative values for X. The problem comes up, when the screen configuration changes (for example multiple users share one Citrix-Account and have

A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll

让人想犯罪 __ 提交于 2020-01-15 07:35:09
问题 I'm trying to make a fullscreen screencapture and load it into an pictureBox, but it's giving me this error: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll Additional information: Ongeldige parameter. Code: using (Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)) { using (Graphics g = Graphics.FromImage(bmpScreenCapture)) { g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen