Results 1 to 16 of 16

Thread: how do drawing programs work?

  1. #1

    Thread Starter
    Hyperactive Member billwagnon's Avatar
    Join Date
    Jul 1999
    Location
    St. Louis, Missouri, Mississippi Valley
    Posts
    290

    how do drawing programs work?

    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?

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Yeah, as a bitmap.
    Use this:
    VB Code:
    1. Function SavePic(Pb As PictureBox, Path As String)
    2.     SavePicture Pb.Image, Path
    3. End Function
    The resulting file size will be enormous.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    Hyperactive Member billwagnon's Avatar
    Join Date
    Jul 1999
    Location
    St. Louis, Missouri, Mississippi Valley
    Posts
    290
    I'm not using a bitmap.

    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.

    Should be smaller than a bitmap.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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:
    1. 'this function creates an enhanced meta file and returns a hdc
    2. 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
    3. 'this function ends recording a meta file and returns a handle to the metafile
    4. Private Declare Function CloseEnhMetaFile Lib "gdi32" (ByVal hdcMetaFile as Long) as Long
    5. 'this function frees the memory associated with a metafile
    6. Private Declare Function DeleteEnhMetaFile Lib"gdi32" (ByVal hEnhMetaFile as Long) as Long
    7. 'this function plays a meta file
    8. Private Declare Function PlayEnhMetaFile Lib "gdi32" (ByVal hdcDest as Long, ByVal hEnhMetaFile as Long, ByRef lpRect as Rect) as Long
    9.  
    10. 'the type Rect
    11. Private Type Rect
    12.   Left as Long
    13.   Top as Long
    14.   Right as Long
    15.   Bottom as Long
    16. 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.

  5. #5
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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.
    Sanity is a full time job

    Puh das war harter Stoff!

  6. #6

    Thread Starter
    Hyperactive Member billwagnon's Avatar
    Join Date
    Jul 1999
    Location
    St. Louis, Missouri, Mississippi Valley
    Posts
    290
    good idea, I'll try that

    Are there any good tutorials that describe this?

  7. #7
    Fanatic Member riis's Avatar
    Join Date
    Nov 2001
    Posts
    551
    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

  8. #8
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    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.

  9. #9
    New Member
    Join Date
    Feb 2002
    Posts
    4

    Here is Mine

    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.

    Here is how it looks.

    Sincerely: Sautin
    Locked,Lifted,Bent,Trimmed 87 Wrangler YJ

  10. #10
    New Member
    Join Date
    Feb 2002
    Posts
    4

    Here is Mine

    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.



    Sincerely: Sautin
    Locked,Lifted,Bent,Trimmed 87 Wrangler YJ
    Attached Files Attached Files

  11. #11
    New Member
    Join Date
    Feb 2002
    Posts
    4

    Sorry You need this

    You have to register this ocx.
    Attached Files Attached Files

  12. #12
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Lightbulb ...ummm....

    Why all the trouble if you can just use

    Code:
    SavePicture myPicture.picture, "c:\test.jpg"
    U can replace .jpg with gif or even Bmp if you want. PCX might also work.
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

  13. #13
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    VB can save jpeg without any extra libs or controls?
    Sanity is a full time job

    Puh das war harter Stoff!

  14. #14
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    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
    "1 4m 4 1337 #4xz0r!'
    Janus

  15. #15
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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!
    Sanity is a full time job

    Puh das war harter Stoff!

  16. #16
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    Ohhh, so is that why all the "jpg's" were so big?
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width