using libgd for images

This is a discussion on using libgd for images within the C++ Programming forums, part of the General Programming Boards category; ok, I'm really just starting with c++, and back in c-land I would use the libgd library to create images. ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    82

    using libgd for images

    ok, I'm really just starting with c++, and back in c-land I would use the libgd library to create images.

    I gather that I can continue to use it in the same way in c++.

    My question is however, _should_ I use it in the same way? i.e. is it the done thing, or best practice, to have c-looking code inside a c++ program? Shouldn't I be putting it all into some class?

    Would there be a "c++-way" of incorporating libgd?

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    I don't know about libgd. But c++ is not only a superset of C, it also is designed to make inter operation with legacy C code easy. Nerveless it's often more convenient to build a more or less thin wrap around the C code which helps converting C++ data structures into the format the C-lib expects, or between C and C++ error handling or even offers an object oriented interface. For many C-libraries such a C++ wrapper does already exist. If not you can decide on your own if it's worth to build one (normally it only is inside bigger projects or if you use the C-lib very often).
    But it's in now way wrong or bad style to use a plain C lib the C-way inside C++ code.
    Last edited by pheres; 04-18-2009 at 08:06 AM.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,629
    A quick search of the Web brings up this discussion in the libgd bug tracker: iostream feature offered for inclusion.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    82
    thanks pheres and laserlight .. those comments were really helpful ... gives me a good eye into c++land!

    Oh sorry, I meant to say (for other readers really) that I looked up boost and it seems to have some image creation abilities which I will also check out.
    Last edited by stabu; 04-19-2009 at 10:40 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem With The Libgd
    By Tonto in forum C++ Programming
    Replies: 4
    Last Post: 03-24-2008, 10:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21