最近做了个简单的画图程序,改自gtk example中的scribble-simple的程序,原来的例子是将报出来的点为基准然后向周围扩散了一个区域。
现在是将报出来的点画成线,
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <gtk/gtk.h>
#include <linux/fb.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <unistd.h>
#define LOG_BUF_MAX 512
#define LINE_LEN 50
#define UPDATEMODE_ADD 0x4004462d // address of update mode
#define UPDATEDATE_ADD 0x4040462e // address of update date
#define FBIOGET_VSCREENINFO 0x4600
#define FBIOGET_FSCREENINFO 0x4602
const char fb_dev[] = "/dev/fb0";
const char log[] = "/fb_ctrol.log";
int log_fd;
struct fb_var_screeninfo info;
void *scrbuf;
int fb_fd;
int cal_val[7];
int lx=0; //last x
int ly=0; //last y
int lx_root=0; //last root x
int ly_root=0; //last root y
int firstpoint = 1;
int NewRegion = 0;
int updateFlag = 1;
struct Rect {
__u32 top;
__u32 left;
__u32 width;
__u32 height;
};
struct mxcfb_rect {
__u32 top;
__u32 left;
__u32 width;
__u32 height;
};
struct mxcfb_alt_buffer_data {
__u32 phys_addr;
__u32 width; /* width of entire buffer */
__u32 height; /* height of entire buffer */
struct mxcfb_rect alt_update_region; /* region within buffer to update */
};
struct mxcfb_update_data {
struct mxcfb_rect update_region;
__u32 waveform_mode;
__u32 update_mode;
__u32 update_marker;
int temp;
uint flags;
struct mxcfb_alt_buffer_data alt_buffer_data;
};
struct mxcfb_update_data upd_data;
struct Rect lastRect;
struct Rect mRect;
GMutex *mutex =