drawing

WPF - UIElement.RenderSize not working for Line shape

I'm trying to make some drawing application and I get strange results in my "selection mode". If I draw a rectangle and "select it" RenderSize returns proper Size for it, but if Line is selected RenderSize returns Size which has Width set as Line.X2, and Height set as Line.Y2. For example: Line begins at X1 = 50, Y1 = 50, ends at X2 = 13...

What are the letters in a XAML Geometry attribute called?

I am defining a XAML DrawingBrush resource and I want to draw a custom shape. I found the following GeometryDrawing example: <GeometryDrawing Geometry="M0,0.1 L0.1,0 1,0.9, 0.9,1z" Brush="Gray" /> What do the M, L, and z letters in the Geometry attribute mean? What are they called? ...

Make +y UP, Move Origin C# System.Drawing.Graphics

I want the origin to be at the center of my window. ______________ | ^ | | | | | o----->| | | |____________| .NET wants it to be in the top left hand corner. _____________> | | | | | | | | V____________| Dot net and I are trying to get along.. Does an...

Is there a way to tile a background image over a canvas path?

For example, I have a canvas in a page with some kind of a path. It is created by javascript this way: var context = $('#some_canvas').getContext('2d'); context.beginPath(); context.lineWidth = 5; context.strokeStyle = '#000000'; context.moveTo(0, 0); context.lineTo(100, 100); context.stroke(); Is there a way to make the path that app...

Drawing once per frame in Cocoa

When I use GLUT, I can provide a callback function that gets called once per frame to generate or animate the frame content. How do I do the same thing with Cocoa? I understand there's setNeedsDisplay, but I don't know how to avoid calling it more than once per frame. What I need is an event or other callback that tells me when to draw...

Ultra fast drawing in DotNET

Initial tests indicate that GDI+ (writing in VB.NET) is not fast enough for my purposes. My application needs to be able to draw tens of thousands of particles (coloured circles, very preferably anti-aliased) in a full screen resolution at 20+ frames per second. I'm hesitant to step away from GDI+ since I also require many of the other ...

How to write to a (Bitmap?) image buffer for faster GDI+ displays?

Using C++ and .net I have a stream of data I want to display as a scrolling image. Each time I get some new data I want to add it as a new row (128x1 pixels) and scroll the previous contents to one side. My first stab at the problem involved rendering the entire data set each time I got a new row. This worked, but was far too slow, so I...

How to make a curve to join two objects editable?

Hi, I'm involved in a project in which we're doing a visual editor (written in Java). Now, I'm trying to make curves that join two different objects that I'm painting in a class that extends JPanel (this class is what I'm using to paint, inside a JFrame, overriding the method paintComponent). I'm in troubles because I'm using the class Q...

C# : How to erase content on a Bitmap

Hi I have C# winForm application which holds a pictureBox control. This control has a Paint event.Every time paint event is fired , a Bitmap is dynamically created and I perform some drawing on it. And when user clicks "save" button , edited image is saved as jpg file. It's OK until now. But when I load a new image in pictureBox contr...

How do i draw more efficiently?

How do i draw this more efficiently? I can feel the lag when i call the code below. NOTE this is about pixel editing and not clearing the screen. int colorIndex = 0; private void pictureBox1_Click(object sender, EventArgs e) { if (colorIndex == 0) draw(Color.DimGray); else if(colorIndex ==1) ...

How do I calculate a four colour gradient?

If I have four colours (A, B, C & D) on four corners of a square and I want to fill that square with a gradient that blends nicely between the four colours how would I calculate the colour of the point E? The closer E is to any of the other points, the strong that colour should affect the result. Any idea how to do that? Speed and sim...

Drawing Colors in a picturebox?

In C# i have a picturebox. i would like to draw 4 colors. The default will be white, red, green, blue. How do i draw these 4 colors stritched in this picbox? or should i have 4 picbox? in that case how do i set the rgb color? ...

How to draw a rectangle on a java applet using mouse drag event and make it stay

I have my program that can draw rectangles. I have two problems I can't solve. After I draw the rectangle it won't stay. The only code I have that clears the canvas in under paint, repaint is only called on mouse drag. Why when I mouse release or mouse move does my canvas clear. The second thing isn't as much a problem, but something I c...

Handling \n in LineBreakMeasurer

There are thousand articles how to use LineBreakMeasurer to draw multi-line text but there is none about drawing multi-line text taking into account also \n(when you want to force a new line at a specific position in text and not only when the right - or left - margin ends). The secret seems to lie in BreakIterator, but I couldn't find ...

Optimizing a drawing (with finger touches) application for iPhone SDK

Hi all, I'm writing an application that uses your finger to draw simple diagrams. I have it working for the most part but now I'm trying to optimize its performance. When the user swipes their finger fast, I can't capture enough touch events to draw a smooth path. Here's my current approach: 1) I subclassed a UIView and added a porop...

how to get Bitsperpixel from a bitmap

Hi, I have a 3rd party component which requires me to give it the bitsperpixel from a bitmap. whats the best way to get "bits per pixel"? I have a c# windows app and my starting point is the following blank method:- public int GetBitsPerPixelMethod( system.drawing.bitmap bitmap ) { //return BitsPerPixel; } At the momement I don...

Speeding up GTK tree view

I'm writing an application for the Maemo platform using pygtk and the rendering speed of the tree view seems to be a problem. Since the application is a media controller I'm using transition animations in the UI. These animations slide the controls into view when moving around the UI. The issue with the tree control is that it is slow. ...

What causes a NullPointerException in the AWT-EventQueue-0 thread

I'm trying to do something to track down the problem, but there's not much I can do until paintContents, and everything there looks good through my debugger, but I'll double check to make sure I didn't miss anything. At the very least, I would like to know how to silently handle these (such as catching them and being able to output a mea...

How to Draw Text Vertically with Compact Framework

I need to draw text VERTICALLY directly on to a Windows Mobile Form. This is a Compact Framework 2.0 application. I have the following test code working in a windows form application, but it does not work with the compact framework because there is NOT a DirectionVertical StringFormatFlag. Is there another way to do the same thing on Win...

How to get the MouseEvent.localX and localY of a target but not its child objects?

I'm creating a simple drawing application that adds new Shape objects to a MovieClip "canvas" every time the user clicks and drags. The problem is, I'm noticing that even though the MouseEvent listeners are set to the MovieClip, the child Shape objects are being returned as targets as well. This disrupts the localX and localY as well, ...