Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread一般讨论
dc画图图出现硬件错误 是什么原因导致的?
发布于 2013-03-17 22:01:20 浏览:1998
订阅该版
``` void button2_deal(struct rtgui_object* object, struct rtgui_event* event) { struct rtgui_win *win1; struct rtgui_widget *widget; struct rtgui_dc *dc; rtgui_color_t color; rtgui_rect_t rect = {0,20,320,240}; win1 = rtgui_win_create(RT_NULL,"l",&rect,RTGUI_WIN_STYLE_DESTROY_ON_CLOSE|RTGUI_WIN_STYLE_CLOSEBOX); widget = RTGUI_WIDGET(win1); dc = rtgui_dc_begin_drawing(widget); if(dc != RT_NULL) { color = RTGUI_DC_FC(dc); RTGUI_DC_FC(dc) = red; rtgui_dc_draw_line(dc,100,100,200,200); RTGUI_DC_FC(dc) = color; rtgui_dc_end_drawing(dc); } rtgui_win_show(win1,RT_FALSE); } ``` 上面这断代码使用dc画一条直线 在dc = rtgui_dc_begin_drawing(widget); 出现硬件错误请问怎么解决?
查看更多
4
个回答
默认排序
按发布时间排序
grissiom
2013-03-17
这家伙很懒,什么也没写!
win1 是否是 NULL?
王周旺
2013-03-17
这家伙很懒,什么也没写!
win的不是 现在已经可以画线了但是有时候一个填充矩形只画一半 有点像画矩形的时候被中断了然后数据就乱了那种情况 代码如下 ``` #include
#include "app.h" /*rtgui_dc绘制基本图形函数*/ static void dc_draw(struct rtgui_widget *widget); /*主窗口事件函数*/ static rt_bool_t event_handler(struct rtgui_object *object, rtgui_event_t *event); /** * @函数名称:event_handler() * @描述 : 主窗口事件服务函数 * @参数 : *object: 事件对象指针,*event:事件类型指针 * @返回值 : rt_bool_t. */ static rt_bool_t event_handler(struct rtgui_object *object, rtgui_event_t *event) { /*将object转换成widget*/ struct rtgui_widget *widget = RTGUI_WIDGET(object); /*输出调试信息*/ rt_kprintf("event_handler "); if(event->type == RTGUI_EVENT_PAINT) //事件类型为RTGUI_EVENT_PAINT { /*输出调试信息*/ rt_kprintf("RTGUI_EVENT_PAINT "); /*执行窗体事件*/ rtgui_win_event_handler((struct rtgui_object*)object, event); /*调用绘制函数绘制图形*/ dc_draw(widget); } else if (event->type == RTGUI_EVENT_SHOW) //事件类型为RTGUI_EVENT_SHOW { /*输出调试信息*/ rt_kprintf("RTGUI_EVENT_SHOW "); rtgui_win_event_handler((struct rtgui_object*)object, event); } else if (event->type == RTGUI_EVENT_HIDE) //事件类型为RTGUI_EVENT_HIDE { /*输出调试信息*/ rt_kprintf("RTGUI_EVENT_HIDE "); rtgui_win_event_handler((struct rtgui_object*)object, event); } else if (event->type == RTGUI_EVENT_WIN_DEACTIVATE) //事件类型为RTGUI_EVENT_WIN_DEACTIVATE { /*输出调试信息*/ rt_kprintf("RTGUI_EVENT_WIN_DEACTIVATE "); rtgui_win_event_handler((struct rtgui_object*)object, event); } else if (event->type == RTGUI_EVENT_KBD) //事件类型为RTGUI_EVENT_KBD { rtgui_win_event_handler((struct rtgui_object*)object, event); } else //不在范围内的事件 { rt_kprintf("event->type:%d ", event->type); return rtgui_win_event_handler((struct rtgui_object*)object, event); } return RT_FALSE; } /** * @函数名称: dc_draw() * @描述 : dc绘图函数,本例子的核心 * @参数 : *widget RTGUi部件指针 * @返回值 : None. */ static void dc_draw(struct rtgui_widget *widget) { /*局部变量*/ struct rtgui_dc *dc; rtgui_color_t tcolor ; rtgui_rect_t rect={100,100,150,200}; /*获得窗体的dc*/ dc=rtgui_dc_begin_drawing(widget); /*存放当前DC的前景色*/ tcolor=RTGUI_DC_FC(dc); /*设置前景色*/ RTGUI_DC_FC(dc)=RTGUI_RGB(0,0,200); /*绘制圆角矩形*/ rtgui_dc_draw_round_rect(dc,&rect,5); /*绘制一条直线*/ rtgui_dc_draw_line(dc,0,0,300,240); /*设置前景色*/ RTGUI_DC_FC(dc) = RTGUI_RGB(200,0,0); /*绘制椭圆*/ //rtgui_dc_draw_ellipse(dc,100,100,50,80); /*设置前景色*/ RTGUI_DC_FC(dc) = RTGUI_RGB(200,0xff,0); /*绘制填充圆*/ rtgui_dc_fill_circle(dc,100,100,50); /*设置前景色*/ RTGUI_DC_FC(dc) = RTGUI_RGB(200,0x00,0xff); /*设置矩形*/ rect.x1=10; rect.y1=100; rect.x2=rect.x1+100; rect.y2=rect.y1+50; /*绘制填充矩形*/ rtgui_dc_fill_rect(dc,&rect); /*设置矩形*/ rect.x1=10; rect.y1=10; rect.x2=rect.x1+200; rect.y2=rect.y1+20; /*设置前景色*/ RTGUI_DC_FC(dc) = RTGUI_RGB(200,0x00,0x00); /*绘制文本*/ rtgui_dc_draw_text(dc,"12345,hello",&rect); /*将原来的前景色设置回去*/ RTGUI_DC_FC(dc) =tcolor; /*结束dc绘图*/ rtgui_dc_end_drawing(dc); rt_kprintf("end "); } void button1_deal(struct rtgui_object* object, struct rtgui_event* event) { struct rtgui_win *win1; struct rtgui_label *label1; rtgui_rect_t rect = {0,20,300,240}; win1 = rtgui_win_create(RT_NULL,"button1",&rect,RTGUI_WIN_STYLE_DESTROY_ON_CLOSE|RTGUI_WIN_STYLE_CLOSEBOX); label1 = rtgui_label_create(""); rect.x1 = 50,rect.y1 = 100; rect.x2 = 300,rect.y2 = 150; RTGUI_WIDGET_BACKGROUND(label1) = red; RTGUI_WIDGET_FOREGROUND(label1) = green; rtgui_label_set_text(label1,"asdfghjkl dfsaf王周旺"); RTGUI_WIDGET_FONT(label1) = rtgui_font_refer("hz",32); rtgui_widget_set_rect(RTGUI_WIDGET(label1),&rect); rtgui_container_add_child(RTGUI_CONTAINER(win1),RTGUI_WIDGET(label1)); rtgui_win_show(win1,RT_FALSE); } void button2_deal(struct rtgui_object* object, struct rtgui_event* event) { struct rtgui_win *win1; struct rtgui_dc *dc; rtgui_color_t color; rtgui_rect_t rect = {0,20,320,240}; win1 = rtgui_win_create(RT_NULL,"l",&rect,RTGUI_WIN_STYLE_DESTROY_ON_CLOSE|RTGUI_WIN_STYLE_CLOSEBOX); rtgui_object_set_event_handler(RTGUI_OBJECT(win1), event_handler); rtgui_win_show(win1,RT_FALSE); } void button3_deal(struct rtgui_object* object, struct rtgui_event* event) { } void button4_deal(struct rtgui_object* object, struct rtgui_event* event) { } void button5_deal(struct rtgui_object* object, struct rtgui_event* event) { } void button6_deal(struct rtgui_object* object, struct rtgui_event* event) { } static void app_lcd(void *parameter) { struct rtgui_app *app1; struct rtgui_win *win1; struct rtgui_button *button1,*button2,*button3,*button4,*button5,*button6; rtgui_image_t *imge1,*imge2,*imge3,*imge4,*imge5,*imge6; rtgui_rect_t rect = {0,0,320,240}; app1 = rtgui_app_create("ICO_app"); win1 = rtgui_win_create(RT_NULL,"ICO_WINDOS",&rect,RTGUI_WIN_STYLE_NO_BORDER|RTGUI_WIN_STYLE_NO_TITLE); RTGUI_WIDGET_BACKGROUND(win1) = black; imge1 = rtgui_image_create_from_file("bmp","/aa/light.bmp",RT_FALSE); imge2 = rtgui_image_create_from_file("bmp","/aa/alarm.bmp",RT_FALSE); imge3 = rtgui_image_create_from_file("bmp","/aa/picture.bmp",RT_FALSE); imge4 = rtgui_image_create_from_file("bmp","/aa/txt.bmp",RT_FALSE); imge5 = rtgui_image_create_from_file("bmp","/aa/setting.bmp",RT_FALSE); imge6 = rtgui_image_create_from_file("bmp","/aa/time.bmp",RT_FALSE); button1 = rtgui_button_create(""); button2 = rtgui_button_create(""); button3 = rtgui_button_create(""); button4 = rtgui_button_create(""); button5 = rtgui_button_create(""); button6 = rtgui_button_create(""); rect.x1 = 40; rect.y1 = 40; rect.x2 = 100;rect.y2 = 100; rtgui_widget_set_rect(RTGUI_WIDGET(button1),&rect); rect.x1 += 90; rect.y1 = 40; rect.x2 += 90;rect.y2 = 100; rtgui_widget_set_rect(RTGUI_WIDGET(button2),&rect); rect.x1 += 90; rect.y1 = 40; rect.x2 += 90;rect.y2 = 100; rtgui_widget_set_rect(RTGUI_WIDGET(button3),&rect); rect.x1 = 40; rect.y1 = 150; rect.x2 = 100;rect.y2 = 210; rtgui_widget_set_rect(RTGUI_WIDGET(button4),&rect); rect.x1 += 90; rect.y1 = 150; rect.x2 += 90;rect.y2 = 210; rtgui_widget_set_rect(RTGUI_WIDGET(button5),&rect); rect.x1 += 90; rect.y1 = 150; rect.x2 += 90;rect.y2 = 210; rtgui_widget_set_rect(RTGUI_WIDGET(button6),&rect); rtgui_button_set_unpressed_image(button1,imge1); rtgui_button_set_unpressed_image(button2,imge2); rtgui_button_set_unpressed_image(button3,imge3); rtgui_button_set_unpressed_image(button4,imge4); rtgui_button_set_unpressed_image(button5,imge5); rtgui_button_set_unpressed_image(button6,imge6); rtgui_button_set_onbutton(button1,button1_deal); rtgui_button_set_onbutton(button2,button2_deal); rtgui_button_set_onbutton(button3,button3_deal); rtgui_button_set_onbutton(button4,button4_deal); rtgui_button_set_onbutton(button5,button5_deal); rtgui_button_set_onbutton(button6,button6_deal); rtgui_container_add_child(RTGUI_CONTAINER(win1),RTGUI_WIDGET(button1)); rtgui_container_add_child(RTGUI_CONTAINER(win1),RTGUI_WIDGET(button2)); rtgui_container_add_child(RTGUI_CONTAINER(win1),RTGUI_WIDGET(button3)); rtgui_container_add_child(RTGUI_CONTAINER(win1),RTGUI_WIDGET(button4)); rtgui_container_add_child(RTGUI_CONTAINER(win1),RTGUI_WIDGET(button5)); rtgui_container_add_child(RTGUI_CONTAINER(win1),RTGUI_WIDGET(button6)); rtgui_win_show(win1,RT_FALSE); rtgui_app_run(app1); rtgui_app_destroy(app1); } void rt_app_init(void) { rt_thread_t init_thread; #if (RT_THREAD_PRIORITY_MAX == 32) init_thread = rt_thread_create("init", app_lcd, RT_NULL, 2048, 20, 20); #else init_thread = rt_thread_create("init", app_lcd, RT_NULL, 2048, 80, 20); #endif if (init_thread != RT_NULL) rt_thread_startup(init_thread); } ```
nongxiaoming
2013-04-14
rt-thread大师兄
这么奇怪?
撰写答案
登录
注册新账号
关注者
0
被浏览
2k
关于作者
王周旺
这家伙很懒,什么也没写!
提问
14
回答
33
被采纳
0
关注TA
发私信
相关问题
1
有关动态模块加载的一篇论文
2
最近的调程序总结
3
晕掉了,这么久都不见layer2的踪影啊
4
继续K9ii的历程
5
[GUI相关] FreeType 2
6
[GUI相关]嵌入式系统中文输入法的设计
7
20081101 RT-Thread开发者聚会总结
8
嵌入式系统基础
9
linux2.4.19在at91rm9200 上的寄存器设置
10
[转]基于嵌入式Linux的通用触摸屏校准程序
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
在RT-Thread Studio中构建前执行python命令
2
研究一了一段时间RTT,直接标准版上手太难,想用nano,但又舍不得组件
3
CherryUSB开发笔记(一):FSDEV USB IP核的 HID Remote WakeUp (USB HID 远程唤醒) 2025-01-18 V1.1
4
RT-thread 缩写字典
5
RT Thread 源码分析笔记 :线程和调度器
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
I2C_IIC
ESP8266
UART
WIZnet_W5500
ota在线升级
PWM
cubemx
flash
freemodbus
BSP
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
flashDB
GD32
socket
编译报错
中断
Debug
rt_mq_消息队列_msg_queue
SFUD
msh
keil_MDK
ulog
MicroPython
C++_cpp
本月问答贡献
出出啊
1517
个答案
342
次被采纳
小小李sunny
1444
个答案
290
次被采纳
张世争
813
个答案
177
次被采纳
crystal266
547
个答案
161
次被采纳
whj467467222
1222
个答案
149
次被采纳
本月文章贡献
聚散无由
2
篇文章
14
次点赞
catcatbing
2
篇文章
4
次点赞
Wade
2
篇文章
2
次点赞
Ghost_Girls
1
篇文章
4
次点赞
xiaorui
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部