views:

98

answers:

3

Hi All developers:

I have come across a project where it is required to draw some 2D graphics on a form under Windows and to be able to perform the following tasks:

  • read image formats jpg, GIF, png, with transparency
  • monitor mouse and keyboard input to this form
  • draw simple 2D shapes, eg. line, ellipse, rectangle, pixel set/clear, polygons, ...
  • draw text with true font types and sizes and measure text sizes for different strings
  • written in C and can be integrated into Visual Studio 2008 C project

I've tried OpenCV but it lacks the transperency, font types, and GIF decoding and other things

I need your help please, It would be good if the library is easy to learn and use

thanks all

+2  A: 

And why not use the GDI built into Windows?

Traditional GDI documentation - http://msdn.microsoft.com/en-us/library/dd145203%28v=VS.85%29.aspx Newer GDI+ documentation - http://msdn.microsoft.com/en-us/library/ms533798%28VS.85%29.aspx

Some more info added:

I guess I don't understand your requirements. Is cross platform support required? If yes, then use C and some of the cross platform libraries people have mentioned. If this is Windows only, then why not use the APIs that come with Windows?

Since your already using Visual Studio and you want ease of learning and development, why don't you use C# and the.NET libraries? In 2010, that is really the easiest way to build Windows only programs. Windows Forms will likely do everything you need. If you really must write in C and you are Windows only, then use GDI+ (or GDI if you need to support older versions of Windows). If you want to learn classic Windows C programming, go to the source - http://www.charlespetzold.com/pw5/.

Michael Levy
+6  A: 

Sounds like a perfect job for SDL

daddz
Plus SDL_image (http://www.libsdl.org/projects/SDL_image/) for image loading and SDL_ttf (http://www.libsdl.org/projects/SDL_ttf/) if you want to render text.
Jon Purdy
A: 

As daddz said, you can use SDL for inputs, and image reading. In order to render your 2D primitives, OpenGL will do the work (be sure to create an OpenGL compatible window while calling SDL_CreateWindow). Concerning font rendering, it is not directly implemented in SDL but a couple of libraries can be used (see Survey Of OpenGL Font Technology).

tibur
thanks for your answer and comment, However I think it looks too complex to use openGL and SDL to come out with a solution, adding the font libraries makes it way too overwhelming technique to solve the design challenge, I think there must be some other more straightforward solution in the world
Mohammad Elwakeel