graphics

Setting A CGContext Transparent Background

I am still struggling with drawing a line with CGContext. I have actually go to line to draw, but now I need the background of the Rect to be transparent so the existing background shows thru. Here's my test code: (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColo...

Drawing Nine Patch onto Canvas (Android)

Hello I'm trying to draw a nine patch onto a Canvas object on the Android. What seems strange is that although I generated my nine patch using the draw9patch tool, the constructor for NinePatch requires an additional byte array called the "chunk" to construct the nine patch. Why isn't this simpler? What is the "chunk"? And if you have ...

magnetism simulation

Hi Say I have p nodes on a n by m pixel 2D surface, I want the nodes to be attracted to each other such that the further they are apart the strong the attraction. But if the distance between two nodes, say d(A,B) is less than some threshold say k then they start to repel. Could anyone get me started on some code on how to update the co-...

How can I find the dimensions of a font drawn on a Graphics object in Java?

I have a Font and a FontMetrics object in my code and I'm drawing a Font onto a Graphics object but I'm not for sure how to find out the dimensions of the font when it's drawn (in pixels). Does anyone know how I could calculate that? ...

How do I fix "java.lang.OutOfMemoryError at sun.misc.Unsafe.allocateMemory(Native Method)"?

I'm making a Java application that uses the Slick library to load images. However, on some computers, I get this error when trying to run the program: Exception in thread "main" java.lang.OutOfMemoryError at sun.misc.Unsafe.allocateMemory(Native Method) at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:99) at java...

how to use JUNG to color & shape vertices and edges

I am facing a problem in using JUNG. I want to draw a network diagram where the vertices will be having different shapes and colors and edges will be dashed or full line in different colors. Since I am a newbie in Java, I am unable to understand the actual architecture of jung. When I use setVertexFillPaintTransformer, it colors all the...

Extracting InDesign CS4 Graphics using C# and COM

I'm trying to get details of the graphics in an InDesign file. For technical reasons I'm using COM. Not my favourite, as (discussed elsewhere in StackOverflow) you have to spend half your life casting. In Theory (!), the code snippet belwo should work. Intellisense shows doc.AllGraphics as returning objects. The CS3 scripting ref...

"Beveled" Shapes in Quartz 2D

I'm familiar with some of the basics of Quartz 2D drawing, like drawing basic shapes and gradients and so on, but I'm not sure how to draw a shape with a "beveled" look, like this: Essentially we've got a shine on one corner, and maybe some shading in the opposite corner. I think -- I didn't make this image, although I'd like to be ab...

2D image rotation, few issues

Hi, I'm adding "mouse rotation" to my 2D drawing program. I've got all the code working, by basically calculating the rotation angle from the original mouse click to wherever the mouse currently is. I also draw a transparent rectangle that rotates, instead of actually rotating the image on every mouse movement event. Now, my problem ...

Rotation matrix for a bicycle

Assume you have a flat plane, with a bicycle resting on it. As the bicycle enters a turn, it leans into the turn with angle theta. At the same time, the bike frame points in the same direction as the bike velocity. Thus, given the bike velocity vector v (assumed to be in the XZ plane) and the lean angle theta, how can you find the rot...

Out Of Memory exception on System.Drawing in a Windows Service

Hi, I am getting in out of memory exception while using system.drawing intensively in my windows service. here is a part of my code: FileStream fs = new FileStream(ImagePath, FileMode.Open, FileAccess.Read); img = (Image)Image.FromStream(fs).Clone(); The exception is not only raised in this point, it is also raised in other points so...

output a jFrame to jpeg or bitmap

I've been working on an assignment, and have all the requirements completed. The project is to compare the differences in runtime between a linear search algorithm and a binary search. I have a graph class that puts out the results of those searches in a xy graph. The graph object is a Turtle class that extends JFrame. Is there any w...

What's the best way to add a GUI to a pygame application?

Are there any good GUIs that support pygame surfaces as a widget within the application? If this isn't possible or practical, what GUI toolkit has the best graphics component? I'm looking to keep the speedy rendering made possible by a SDL wrapper. ...

Is it possible to achieve MAX(As,Ad) openGL blending?

I am working on a game where I want to create shadows under a series of sprites on a grid. The shadows are larger than the sprites themselves and the sprites are animated (i.e. move and rotate). I cannot simply render them into the sprite png, or the shadows will overlap adjacent sprites. I also cannot simply put shadows on a lower la...

Performance issue with QGraphicsScene::createItemGroup

I'm using the Qt graphics API to display layers in some GIS software. Each layer is a group, containing graphic primitives. I have a performance issue when loading fairly large data sets, for example this is what happens when making a group composed of ~96k circular paths (points from a shapefile): The complete callgrind dump is here...

GDI GradientFill not working on offscreen bitmap

Hi, I am trying to use the GDI GradientFill function to draw on a offscreen bitmap, then BitBlt that to the screen. But I always get a black bitmap... if I GradientFill directly to the screen it works. Below is a sample app to see what I mean. #pragma comment(lib, "msimg32.lib") #include <windows.h> const CHAR c_szWndClass[] = "Grad...

How to separate an image into two with java

Hi, I'm wondering if there is a "smart" way of splitting an image based on certain features. The images are 300x57, black and white (actually grayscale, but most colors are either black or white), it is comprised of two main features (let's call them blobs) separated by black space, each blob slightly varies in width and height, the pos...

Get Font Glyphs as Vectors, manipulate and product SVG or Bitmap

I have an application that needs to apply some transformations to text (including non-affine transformations). Does anyone know of a toolkit (or group of tools) that would let me bring in a True Type or Postscript Font, get the glyphs as outlines, then apply transformations to the outlines and render it as a bitmap or svg file ? Flash wo...

A native sdk function to scale Bitmap?

Hello! Is there some native android SDK function which takes bitmap and desired new bitmap dimensions and then returns scaled bitmap? ...

Plotting a Decimal valued Points in Java

I am Creating a Graph Plotting Software in java. As a part of process if the equation is of form of y = Sin(x) * Cos(x) then in that case the value of y is a decimal valued points. But in Java we are allowed to plot only integer points. Is there any way to plot points in decimal format using any package ??? The Another strategy that ca...