GTK简单画图程序

基于GTK的简单画图应用,改造自gtk example的scribble-simple,原本以点为中心扩散作画,现在则将点击的点连成线条。
摘要由CSDN通过智能技术生成

最近做了个简单的画图程序,改自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 =
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值