I made a simple drawing program using the line object. When you click, another line (control array) is added. If you click a lot while you move the mouse, you get a curve.
Is this how most of the programs work? Is there a simple way to save the image as a file?
But I could save the line values as x1, x2 and y1, y2 coordinates to a text file. To redraw I'll open the text file and reload the same lines with the saved coordinates.
You could save every mouse click, and when the user wants to save the file, you "replay" the events, but you don't write to teh screen dc, but rather to a meta file dc.
VB Code:
'this function creates an enhanced meta file and returns a hdc
Private Declare Function CreateEnhMetaFile Lib "gdi32" Alias "CreateEnhMetaFileA" (ByVal hdcRef as Long, ByVal szFileName as String, ByRef lpRect as Rect, ByVal lpDescription as String) as Long
'this function ends recording a meta file and returns a handle to the metafile
Private Declare Function CloseEnhMetaFile Lib "gdi32" (ByVal hdcMetaFile as Long) as Long
'this function frees the memory associated with a metafile
Private Declare Function DeleteEnhMetaFile Lib"gdi32" (ByVal hEnhMetaFile as Long) as Long
'this function plays a meta file
Private Declare Function PlayEnhMetaFile Lib "gdi32" (ByVal hdcDest as Long, ByVal hEnhMetaFile as Long, ByRef lpRect as Rect) as Long
'the type Rect
Private Type Rect
Left as Long
Top as Long
Right as Long
Bottom as Long
End Type
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
is there any real reason why you don't want to use bitmap?
You could use the drawline instead of using a control array which makes things go slow real soon. Also you could use the mouse move event to draw without clicking a lot, but just holding down the mouse button.
Most CAD and GIS programs store their data in binary files. You might have a look at some of them, there's a section for GIS formats at http://www.wotsit.org. Not all formats are open, but quite a big deal of them are.
Of course you'll need to know how you can read from and write to binary files. A good format to start with is ESRI's ArcView Shape file definition. It's relatively easy (compared to other formats), and you don't need to purchase any software or register external DLL's to handle Shape files.
CornedBee, those API calls for Enhanced Meta Files sound interesting. I'll have a look at them
You really should use WMF/EMF files. They are very very scalable without loosing the fine details. When scaling bitmaps, you ALWAYS lose some resolution, despite of the a-aliasing.
Especially when printing the drawing to a printer, the difference will be quiet obvious.
I have a graphics drawing program, it only simulates 3d, but it works really well, everything is saved to a binary file, (Workspace info, objects etc.) you can even extrude by opening an object. It is pretty cool. The real 3d stuff will come when I get a chance to rewrite the program specifically for use with opengl.
I have a graphics drawing program, it only simulates 3d, but it works really well, everything is saved to a binary file, (Workspace info, objects etc.) you can even extrude by opening an object. It is pretty cool. The real 3d stuff will come when I get a chance to rewrite the program specifically for use with opengl.
LOL, no, it just saves it with that extension, and then if you load it with loadpicture VB recognizes the BMP header in your JPG or GIF file and loads it properly. VB doesn't even LOAD PCX files, let alone SAVE them. :P
that's what I thought, but you never stop learning and I was kind of wondering if saving jpg would be integrated in the .net. I think it's about time they do so!