graphics

How to save the frame buffer and then retrieve it back..

hi I'm very much new to openGL and I'm trying to do a small project something like a paint tool.. so i just want to save all the things in frame buffer to be saved in a file and to retrieve them back.. ...

Fast method to rotate image in .NET Compact Framework in C#

Is there a fast way to rotate images in .NET Compact Framework. I've found ways to do 90, 180,270, rotations but would like to be able to rotate images free form in similar speed. ...

Need a way to scale a font to fit a rectangle.

I just wrote some code to scale a font to fit within (the length of) a rectangle. It starts at 18 width and iterates down until it fits. This seems horribly inefficient, but I can't find a non-looping way to do it. This line is for labels in a game grid that scales, so I can't see a work-around solution (wrapping, cutting off and exten...

How can I repaint efficiently when using big custom component in Swing?

I have made a custom component (derived from JComponent) which represents a draggable Bezier-curve. (looks like a hanging cable, someone might know it from Bender or Cubase) My problem is: The curve may become really long, let's say from top left to bottom right corners of the desktop. This makes Swing's repaint functionality inefficie...

Graphics.DrawImage logo scaling incorrectly on a large image

I'm doing some standard code, I am applying a logo to an image and it is working fine. The source image is always 1024 x 768 as the code before this takes the image and resizes it (creates a new file based on the original). The logo is applied correctly on some images I have that are 2288 x 1712. If I use an image of 3264 x 2448 then t...

When is a Swing component 'displayable'?

Is there a way (e.g., via an event?) to determine when a Swing component becomes 'displayable' -- as per the Javadocs for Component.getGraphics? The reason I'm trying to do this is so that I can then call getGraphics(), and pass that to my 'rendering strategy' for the component. I've tried adding a ComponentListener, but componentShown...

Drawing part of a Bézier curve by reusing a basic Bézier-curve-function?

Assuming I'm using some graphic API which allows me to draw bezier curves by specifying the 4 necessary points: start, end, two control points. Can I reuse this function to draw x percent of the 'original' curve (by adjusting the control points and the end point)? Or is it impossible? Unnecessary information, should someone care: ...

Any good library for generating graphs for the iPhone?

I need a charting library that could work on the Iphone standalone (no Internet). I only need bars & pie. Is for a bussines-oriented app. If not exist, then how integrate a JS one? ...

Swing: How to read graphic information underneath a component?

Hello! How could I "read" graphic information underneath a component (let's say as BufferedImage)? I want to make that component half-translucent (already done) and apply graphic effects on underlying stuff, such as blur all elements under that component (but not the component itself). My approach is probable wrong: I try to get gra...

Need a function to limit a line (known by its coordinates) in its length

Hello! I need a function which takes a line (known by its coordinates) and return a line with same angle, but limited to certain length. My code gives correct values only when the line is turned 'right' (proven only empirically, sorry). Am I missing something? public static double getAngleOfLine(int x1, int y1, int x2, int y2) { do...

Calculating the Bounding Rectangle at an Angle of a Polygon

I have the need to determine the bounding rectangle for a polygon at an arbitrary angle. This picture illustrates what I need to do: The pink rectangle is what I need to determine at various angles for simple 2d polygons. Any solutions are much appreciated! Edit: Thanks for the answers, I got it working once I got the center point...

What is the best way to create a realistic highlighter in .NET (using GDI+)?

How can i create a realistic highlighter (simulating a real world highlighter pen) in .NET using GDI+? It is meant to be used on a graphics object not on selectable text. Using a transparent brush (with alpha channel) doesn't do the job since everything below the area covered by the brush gets "fuzzy", and i would like the "foreground" ...

Implementing copy, cut and paste

I want to implement copy, cut and paste in my drawing program (copy part of an image that is selected) I don't know how to start Any Ideas? ...

Memory leaks in image creation function

Hi, I am currently working on an iPhone game, and need to create some animation on the fly. The animation is based on several images, and as the range of image combinations is too large and it is impossible to pre-create all of sequences, I'd like to be able to recalculate a set of images every time the situation changes. The function ...

Tetris and pretty graphics

Say you're building a Tetris game. As any proper programmer, you have your view logic on one side, and your business logic on the other side; probably a full-on MVC going on. When the model sends its update(), the view redraws itself, as expected. But then... if you wanted to add, say, an animation to vanish a line, how would you imple...

Ball to Ball Collision - Gains significant velocity upon collision

I implemented the code from the question "Ball to Ball Collision - Detection and Handling" in Objective-C. However, whenever the balls collide at an angle their velocity increases dramatically. All of the vector math is done using cocos2d-iphone, with the header CGPointExtension.h. What is the cause of this undesired acceleration? The f...

Stacking Cg shaders

In my engine I load Cg shaders from pairs of vertex/pixel shader files. I would like to be able to stack shaders to combine them (lighting + material, etc.). Short of breaking up the shaders into separate functions and then creating a single shader script string from those, do you know of any good ways of stacking different shaders in Cg...

Buttons for website

I need to create some buttons for a web app. However, I have no graphics/Photoshop skills at all. Is there a website/software out there that I can simply enter the text for my button and it will spit out a graphical image with those words on top? I don't mind avoiding graphics altogether, but the links must look like a button. e.g. a b...

What is the minimum boilerplate code for a OpenGL 2D View?

What's the minimum boilerplate code required to setup an OpenGL view (with the necessary projections,camera angles etc) for drawing a 2D game? For example, the minimum required to do Quartz 2D drawing in a custom view (and, say, load a background image) is the following: #import <Cocoa/Cocoa.h> @interface MyView : NSView { } @end =...

The Need To Restore Graphics Original State When Overwritten paint or paintComponent

Hello all, I realize most of the Java code to overwritten paint or paintComponent, most of them doesn't restore the old state of graphics object, after they had change the state of graphics object. For example, setStroke, setRenderingHint... I was wondering whether it is a good practice that we restore back the old state of graphics ob...