graphics

Calculating pixel size on an iPhone

Is there a way in the iPhone SDK to calculate the size (in millimeters) of a single pixel? ...

Writing BMP data getting garbage

I'm working on understanding and drawing my own DLL for PDF417 (2d barcodes). Anyhow, the actual drawing of the file is perfect, and in correct boundaries of 32 bits (as monochrome result). At the time of writing the data, the following is a memory dump as copied from C++ Visual Studio memory dump of the pointer to the bmp buffer. Eac...

Minimize Polygon Vertices

What is a good algorithm for reducing the number of vertices in a polygon without changing the way it looks very much? Input: A polygon, represented as a list of points, with way too many verticies: raw input from the mouse, for example. Output: A polygon with much fewer verticies that still looks a lot like the original: something usa...

Are there any good / interesting analogs to regular expressions in 2d?

Are there any good (or at least interesting but flawed) analogs to regular expressions in two dimensions? In one dimension I can write something like /aaac?(bc)*b?aaa/ to quickly pull out a region of alternating bs and cs with a border of at least three as. Perhaps as importantly, I can come back a month later and see at a glance what ...

Gdiplus 64bit colors

I am creating a 64bit bitmap and wrapping it using Graphics object to draw over it. Problem is Gdiplus Color class is only 32bit(each component is byte only i.e.max 255) so how can I draw over a 64bit image using gdiplus? e.g. Bitmap bmp(100, 100, PixelFormat64bppARGB); Graphics g(&bmp); //how do I draw a red line now, if i use Color(2...

Best approach for game animation?

I have a course exercise in OpenGL to write a game with simple animation of a few objects While discussing with my partner our design options we've realized we have two major choices for how the animation is going to work, Either Set a timer for a constant interval, say 30 msec, when the timer hits, calculate where objects should be...

Separating axis test, detecting if a rotated rectangle overlap an other flat rectangle

Hello, I read about intersection rectangles on: http://stackoverflow.com/questions/115426/algorithm-to-detect-intersection-of-two-rectangles But i have trouble to implement it. If R1 (A,B,C,D) is my rotated rectangle and R2(A',B',C',D') the other rectangle with no rotation. The formula extracted in from the link above is: edge = ...

When to use OpenGL instead of GTK or QT library?

I understand the purpose of GTK, QT or other graphic toolkits. But I don't understand the role of OpenGL. Is it just another GUI-library or does it refer to something more fundamental? If so, what is it and when should I use it in day-by-day hacking? ...

Which floating-point image format should I use ?

In the past I've saved RGB images (generated from physical simulations) as 8-bits/channel PPM or PNG or JPEG. Now I want to preserve the dynamic range of the simulation output, which means saving a floating point image and then treating conversion to 8-bits/channel as a post-processing step (so I can tweak the conversion to 8-bit withou...

What's the best way of working with an artist on a WPF application?

I'm about to finish the core components of my application and I'm willing to change gears soon and do a bit of GUI programming. From the beginning I decided to write a WPF-based application for two reasons: a) I want my application to be visually stunning and 100% skineable. b) I completely suck at designing user interfaces and then som...

Ruby library to generate graphics from text?

I'm working in Rails and I'm looking for a library/gem/plugin to generate a graphic from text. Google Maps doesn't allow you to overlay text, only graphics so I'm looking for a back door to overlay text. Suggestions? ...

Problem regarding c-graphics

sir, In my turbo c++ program, I can't run any of the graphics program. When it compile, it shows the error's like: undefined symbol _line, _closegraph,_ getmaxx etc... Is it due to the settings of my c-program? ...

Resizing an image with alpha channel

I am writing some code to generate images - essentially I have a source image that is large and includes transparent regions. I use GDI+ to open that image and add additional objects. What I want to do next is to save this new image much smaller, so I used the Bitmap constructor that takes a source Image object and a height and width, ...

Using Graphics.copyArea with transparent image

I'm trying to shift a portion of an image, currently using g.copyArea(). It works fine with solid colors, but the transparent pixels aren't being copied (because they're transparent!). I want to make the color underneath transparent. This image shows what's happening, if a start shape was copied, but I want the whole area to copy, overw...

.NET equivalent or alternative to Java's GlyphVector?

I'm in the process of porting a Java program to .NET using IKVM. Unfortunately IKVM's Graphics2D implementation throws a NotImplementedException in drawGlyphVector, i.e. it needs to be "fleshed out" with a .NET implementation (or by reducing it to calls of other IKVM Graphics2D methods which are implemented). Any ideas for an equivalent...

Howto perform a MULTIPLY composite effect using Graphics2D

I have two different javax.swing.Icon objects and I want to a create new Icon which is the composite of these two. I want the composite to be a MULTIPLY effect, similair to what you would get in any photoshop-like image editing application when you choose that option. Specifically, per every pixel, if you have color Ca and Cb from image ...

j2me - Rotate array of 2d points in 45 degree increments

I'm working on a roguelike style cellphone game that operates on a grid. Attacks/Items in this game operate by targeting tiles in a pattern relative to the user. The paturn is usually relative to the direction the user is aiming in as well, For instance in this screenshot the pattern Point2d[] damageTiles = new Point2d[4]; ...

Tackling alpha blend in OpenGL for better performance

Since having blends is hitting perfomance of our game, we tried several blending strategies for creating the "illusion" of blending. One of them is drawing a sprite every odd frame, resulting in the sprite being visible half of the time. The effect is quit good. (You'd need a proper frame rate by the way, else your sprite would be notice...

Drawing a Rotated Rectangle

Hello, I realize this might be more of a math problem. To draw the lines for my rectangles I need to solve for their corners. I have a rectangle center at (x,y) With a defined Width and Height. To find the blue points on a non rotated rectangle on top (angle = 0) It is UL = (x-Width/2),(y+height/2) UR = (x+Width/2),(y+height/2) LR ...

Calling a Java method with the implicit Graphics parameter, like repaint() or accessing the Graphics in a JPanel.

When you call repaint(), for example, repaintComponent(Graphics) gets called, and then you can call it from outside the class without the parameter Graphics. I'd like to have a function that takes more parameters I'm using, but I still want to be able to draw with it, so I need to be able to make a call like that (eg repaint() calls rep...