Use GraphicsPath. Unfortunately you can't serialize a GraphicsPath oblect, but you can save the PathPoints[^] array, PathTypes[^] array and the FillMode[^], and then restore the GraphicsPath by the GraphicsPath Constructor (Point[], Byte[], FillMode)[^]. Also keep extra info for the colors of pens or brushes etc, that you use to draw or fill a GraphicsPath.
oobimoo
Posts
-
how can i save the images,circles,rectangle,lines or etc together.. -
How to marshal string array from C# to VB?As far as i know, vb uses the SafeArray (UnmanagedType enumeration[^])
-
Marshal.Copy -
Marshal.CopyPerhaps because uint type is not CLS[^]-compliant.
-
Binary Tree from preorder traversalaksgh wrote:
Its a huffman tree.
Yes didnt see that, you are right. So, for a huffman tree you could the following
typedef struct _node_info {
int is_leaf;
char value;
}node_info;typedef struct _node {
node_info inf;
node* l;
node* r;
} node;// returns the root of the tree, from an array of node_info's structs, that
// represents the preorder traversal of the huffman tree. we assume a global stack s
// initially empty
node* built_tree(node_info* preorder_array, int preorder_array_size)
{
node *root, *n;
int i;
root = malloc(sizeof(node));
stack_push(s, root);
for (i = 0; i < preorder_array_size; i++) {
assert(!stack_empty(s));
n = stack_pop(s);
n->inf = preorder_array[i];
if (!n->inf.is_leaf) {
n->r = malloc(sizeof(node));
stack_push(s, n->r);
n->l = malloc(sizeof(node));
stack_push(s, n->l);
}
}
assert(stack_empty(s));
return root;
}* i dont set r,l members to zero when i create a node, in order to save some space, but it is something you must do
modified on Friday, September 19, 2008 8:09 AM
-
Binary Tree from preorder traversalYou may get the same sequence from different binary trees. So its not possible.
-
brush problem in c#...You can use a pen instead. First adjust the width of your pen. Then set StartCap and EndCap of the pen to LineCap.Round. Finally draw lines, instead of 'points', from the previous point to the current point, in the mouse move event.
-
Huffman coding IssueFirst four bytes of the header -> size of header
-
Callback with meber functions -
How can I get the ISO-Language identifier of the current user? -
My sound stops playing when the form loses focusSet BufferDescription's GlobalFocus property to true
-
Drawing a big image to real coordinatesUse the following class
using System;
using System.Drawing;
using System.Drawing.Drawing2D;namespace some_namespace
{
class Transformation
{
// world: the real world your bitmap represents
// bitmap: your (unscaled) bitmap
// screen: the portion of the screen that you display the image (a picture box maybe)Matrix matrix\_world; // bitmap to world Matrix inv\_matrix\_world; // world to bitmap Matrix matrix\_bitmap; // screen to bitmap Matrix inv\_matrix\_bitmap; // bitmap to screen Size bitmap\_size; Size screen\_size; public Transformation(PointF worldOrigin, SizeF worldSize, Size bitmapSize, Size screenSize) { matrix\_world = new Matrix(); matrix\_bitmap = new Matrix(); bitmap\_size = bitmapSize; screen\_size = screenSize; // if you want the native y-points up coord system for the world, uncomment '-' and // '+ worldSize.Height' below matrix\_world.Scale(worldSize.Width / (float)bitmap\_size.Width, /\* - \*/ worldSize.Height / (float)bitmap\_size.Height); matrix\_world.Translate(worldOrigin.X, worldOrigin.Y /\* + worldSize.Height \*/, MatrixOrder.Append); inv\_matrix\_world = matrix\_world.Clone(); inv\_matrix\_world.Invert(); Reset(); } // Reset transformation to the 'screen portion displays entire bitmap' public void Reset() { matrix\_bitmap.Reset(); matrix\_bitmap.Scale((float)bitmap\_size.Width / (float)screen\_size.Width, (float)bitmap\_size.Height / (float)screen\_size.Height); inv\_matrix\_bitmap = matrix\_bitmap.Clone(); inv\_matrix\_bitmap.Invert(); } // transform to 'screen portion displays the rectangular portion of the bitmap // defined by the displayOrigin point and the displaySize' public void Transform(PointF displayOrigin, SizeF displaySize) { matrix\_bitmap.Reset(); matrix\_bitmap.Scale(displaySize.Width / (float)screen\_size.Width, displaySize.Height / (float)screen\_size.Height); matrix\_bitmap.Translate(displayOrigin.X, displayOrigin.Y, MatrixOrder.Append); inv\_matrix\_bitmap = matrix\_bitmap.Clone(); inv\_matrix\_bitmap.Invert(); }
-
Drawing a big image to real coordinatesYou want to fit a 25000x25000 bitmap in a 1000x1000 bitmap without losing precision? :wtf:
-
How do I draw a single color transparently? -
how to define global const class variable [modified]You must declare extern the g_Info in the MyInfoArrayClass.h header, under the declaration of the class (or add a forward declaration of your class above the const extern CMyInfoArrayClass g_Info;).
-
create a plane thru 3 points (c++)Googling 'plane equation three points' ... 1st result : Equation of a plane[^] Googling 'projection point plane' ... 3rd result : Projection of a point on a plane[^] You could do this, dont you?
-
Having problem in figuring out the logic (c++)raesa wrote:
If i take the min/max of all the three dimesnsions(x,y&z) i might get 6 different points (3points for minimum values of x/y/z and 3 for maximum values of x/y/z), right? Do you suggest me that i will have to compare and find out if my new point cordinates(x1, y1, z1) is either greater or less than the any of the (x,y,z)values of the 6 points? Which means that if any one value (either x1/y1/z1) is greater than the (x/y/z) of the 6 points, the new point lies outside the point cloud.
What I understood, is that Cedric suggested to test if the point p(x,y,z) is in the bounding box of this set of points. And you do this by just comparing
if((x>=XMIN)&&(x<=XMAX)&&(y>=YMIN)&&(y<=YMAX)&&(z>=ZMIN)&&(z<=ZMAX))
. So, if by the word "cloud" you mean bounding box, it's ok. If you mean "convex hull" it's a quite different problem. And although the 2d version of this problem is a common topic for an introductive to algorithms class, I don’t know much about the 3d case. Definitely this question belongs in an algorithms forum. Meanwhile search for “convex hull from set of 3d points”, and “point in convex hull of 3d points” algorithms. my intuition: linear programming problemmodified on Thursday, August 28, 2008 1:56 PM
-
How to freeze an application?1. With a System.Timers.Timer just use the Stop() method to stop the timer. 2. With a System.Threading.Timer, just don't use this timer (why? read documentation). Replace with a System.Timers.Timer 3. For good performance forget timers. Force rendering into app's main loop (as Greeeg mentioned)
modified on Wednesday, August 27, 2008 8:03 AM
-
Clear Text Into BMPWhat are you trying to do? (probably double buffering is the answer to your problem)
-
Sending a String using SendMessageYour are welcome From the msdn (WM_COPYDATA) : "The receiving application should consider the data read-only. The lParam parameter is valid only during the processing of the message. The receiving application should not free the memory referenced by lParam. If the receiving application must access the data after SendMessage returns, it must copy the data into a local buffer. " From the msdn (SendMessage) : "The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message. "
modified on Monday, August 25, 2008 1:08 PM