cairographics glade gtk3 c programming - c

I'm trying to develop an app using GTK3 + Glade and following examples and suggestions on internet I can obtain a first prototype of the application.
Now I want to add some plots in the app. I found that, in this contest, the Cairo library is the right solution. For the Cairo library I found this tutorial http://zetcode.com/gfx/cairo/
I tried to merge GTK3, Glade and Cairo using the C language but I'm not sure to use this tools in the right way.
Could you suggest me an example where using these tools is built an app that, e.g. pushing a button appear the plot of a curve?
Thank you

In Glade, you just need to add a GtkDrawingArea and you draw in it using cairo. Give a look at my gtk3-graph sample application that uses GTK+ 3 and cairo to plot a curve.

Related

What to use when drawing shapes in C?

I've been having some problems trying to figure out with header is useful to manage to get a screen, and draw shapes in it, using C.
Tried to use 'graphics.h' but is not working for me, I think maybe 'graphics.h' is meant to be used in C++ and not C? I really don't know and would appreciate it if someone knows anything.
On Linux, you can't build a graphical app using only stdlib. You have to add something like OpenGL, Xlib, maybe Qt or even SFML. Good luck to make an app)
I believe graphics.h is a Windows-specific library. Assuming you're on Linux, you can use gfx.
gfx is an xlib-based graphics library with some very basic functions to draw lines/pixels and get keyboard input. I wouldn't use it in a serious project, but it's fairly easy to get started with. You can even add functionality to draw more complex shapes if you mess with the source code and some XLib functions.
If that's too basic, you can use SDL2 for 2D graphics, OpenGL for 3D graphics, and ncurses for terminal-based graphics.

Making a GUI simulator in C

Hello StackOverflow Community,
I am writing a MicroMouse Simulator in C language. And I wanted something to visualize the way the maze is being solved like this -- http://www.youtube.com/watch?v=N9TkDgJNJso
I've been researching a way to accomplish this, but I haven't found anything with enough documentation to accomplish my goal.
I don't want to implement this using ASCII symbols, to me it doesn't look professional.
Is there any good GUI interfaces that I could use in C to help me accomplish this? And if so, how would I use it? I don't mind having to code in another language like Java or Python to accomplish my goal.
I saw the video that you want to make. After watching the video I feel you don't need a GUI library for this simulator program.
Here is a list of libraries that you can use.
1.OpenGL This is a 3D graphics API which also can be used for 2D and can be used with both c/c++
2.SDL This library is easy to understand for a beginner. For your program this library is better and can be used with both c/c++.
3.winBGIm This is same as the graphics.h that you found and can be used both c/c++ but it is only for windows.
If you are looking for GUI library then here's a short list.
1.GTK This is written in c and is a popular GUI library for c. You can find a GUI editor for gtk forms called glade which enables quick & easy development of user interfaces.
2.WxWidgets This is written in c++ so you have to use c++ rather than c.
3.FLTK
There are many more libraries besides these which you can find in google. You said
I do not mind having to code in another language like Java or Python to accomplish my goal.
Then for java you can use swing and If you are windows developer then use the windows form application in visual c++; then development of your program will be very easy.
SDL is one of candidate for C in order to make GUI Simulation. Lazyfoo is one of the best site I found for beginner.
SDL is strongly portable. It's written in C and there're a lot of documentation and tutorials.

What lib is usually to be used to develop a simple game like Tetris?

I am going to develop a Tetris in practice. But I have no idea how to start it, especially the graphic part - how to draw the frame and blocks? how to move them on screen?
Could you please you refer me to some useful libs or tools?
Programming language is c. (if this is done, I am planing to do it again with c++ and python. :) Both Windows or Unix-like is ok. It's better if it is portable.
I know openGL, and DirectX is heavy-weight lib. dose it efficiently fit to a small game like Tetris? Any light-weight? which is better?
I would appreciate if you could refer me to some materials or links for this.
Thanks.
If you'd like to keep your game in a window and not full-screen, then any library that implements some type of paintable canvas widget will work. Cross-platform candidates include Qt, WxWidgets, FLTK, GTK+, etc. If you want to remain on a single platform like Windows, then you can use a lower-level Win32 API like GDI+. As I mentioned in my first sentence, with most of these libraries/API's, you'd be looking to use their paintable canvas widgets, allowing you to draw the characters shapes on the window. You'd also use some type of timer event to periodically update the drawn window at fixed time intervals.
You can use SDL - is simple and many platforms are supported
I would suggest SDL or Allegro. Both provide simple ways of getting input and doing graphics and audio output. And both are multiplatform.

How to rotate image in android using android ndk

i want to rotate bitmap in android . i don't want to use android api but want to use c code for image processing and fast response. can u tell me how to achieve this in c??
Thank you in advance
You could use OpenCV for Android by processing a rotation matrix in native code. But if you really just want to rotate an image, using native code for this would be over the top, unless you plan adding more complex transformations. A single transformation supposedly won't be processed faster in comparison to just rotating it in Java.
There is a nice solution for your needs: ImageMagick. You can compile C version of ImageMagick with NDK. There is also ImageMagick-Android project on github, but it doesn't look like a ready-to-use solution.

How to implement DirectShow Library to build a WPF Application

How to implement DirectShow Library to build a WPF Application that can make
1. capture the video from webcam
2. screen capture to a video file
I try to find example code for the absolutely beginner
This codeplex project (Touchless) should give you a head start. It is pretty easy to look at the code and see how it works.

Resources