framebuffer在Ubuntu上的操作

一,frambuffer.c

1.头文件及结构体

#include "framebuffer.h"
#include <linux/fb.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <math.h>void *pmem;
struct fb_var_screeninfo vinf;

2.初始化framebuffer

int init_fb(char *devname)
{//1. 打开显示设备int fd = open(devname, O_RDWR);	if (-1 == fd){perror("fail open fb");return -1;}//2、获取显示设备相关参数 分辨率 位深度int ret = ioctl(fd, FBIOGET_VSCREENINFO, &vinf);if (-1 ==ret){perror("fail ioctl");return -1;}printf("xres = %d, yres = %d\n", vinf.xres, vinf.yres);printf("xres_virtual = %d, yres_virtual = %d\n", vinf.xres_virtual, vinf.yres_virtual);printf("bits_per_pixel : %d\n", vinf.bits_per_pixel);size_t len = vinf.xres_virtual * vinf.yres_virtual * vinf.bits_per_pixel/8;//3, 建立显存和用户空间的映射关系pmem = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);if ((void *)-1 == pmem){perror("fail mmap");return -1;}return fd;
}

3.画一个点

void draw_point(int x, int y, unsigned int col)
{if (x >= vinf.xres || y >= vinf.yres){return ;}if (vinf.bits_per_pixel == RGB888_FMT){unsigned int *p = pmem;*(p + y * vinf.xres_virtual + x) = col;}else if (vinf.bits_per_pixel == RGB565_FMT){unsigned short *p  = pmem;	*(p + y * vinf.xres_virtual + x) = col;}return ;
}

4.销毁

void uninit_fb(int fd)
{size_t len = vinf.xres_virtual * vinf.yres_virtual * vinf.bits_per_pixel/8;munmap(pmem, len);close(fd);
}

5.清屏

void draw_clear(unsigned int col)
{for (int j = 0; j < vinf.xres; j++){for (int i = 0; i < vinf.yres; i++){draw_point(i, j, col);}}
}

6.绘制横线,竖线,矩形,斜线,圆

void draw_h_line(int x, int y, int len, unsigned int col)
{for (int i = x; i < x+len; i++){draw_point(i, y, col);}
}
void draw_s_line(int x, int y, int len, unsigned int col)
{for (int i = y; i < y+len; i++){draw_point(x, i, col);}
}void draw_rectangle(int x, int y, int w, int h, unsigned int col)
{draw_h_line(x, y, w, col);draw_s_line(x, y, h, col);draw_s_line(x+w, y, h, col);draw_h_line(x, y+h, w, col);
}void draw_x_line(int x1, int y1, int x2, int y2, unsigned int col)
{int x = 0;int y = 0;if (x1 == x2){if (y2 > y1){draw_s_line(x1, y1, y2-y1, col);}else{draw_s_line(x2, y2, y1-y2, col);		}}double k = (double)(y2-y1)/(double)(x2-x1);double b = y1 - k*x1;for (int x = (x1 > x2 ? x2 : x1); x <= (x1 > x2 ? x1 : x2); x++){y = x * k + b;draw_point(x, y, col);}return ;
}void draw_circle(int x0, int y0, int r, unsigned int col)
{int x = 0;int y = 0;for (double si = 0; si <= 360; si+=0.01){x = r * cos(2 * 3.14159/360 *si) + x0;y = r * sin(2 * 3.14159/360 *si) + y0;draw_point(x, y, col);draw_point(x-1, y, col);draw_point(x+1, y, col);draw_point(x, y-1, col);draw_point(x, y+1, col);}}

7.绘制bmp格式图像

void draw_bmp(int x, int y, char *picname, int w, int h)
{int fd = open(picname, O_RDONLY);if (-1 == fd){perror("fail open bmp");return ;}lseek(fd, 54, SEEK_SET);unsigned char r, g, b;unsigned char *buff = malloc(w*h*3);read(fd, buff, w*h*3);unsigned char *p = buff;for (int j = h-1; j >= 0; j--){for (int i = 0; i < w; i++){b = *p; p++;g = *p; p++;r = *p; p++;if (vinf.bits_per_pixel == RGB888_FMT){unsigned int col = (r << 16) | (g << 8) | (b << 0);draw_point(i+x, j+y, col);}else if (vinf.bits_per_pixel == RGB565_FMT){unsigned short col = ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0);draw_point(i+x, j+y, col);}}}free(buff);close(fd);
}

8.绘制一个字

void draw_word(int x, int y, unsigned char *word, int w, int h, unsigned int col)
{for (int j = 0; j < h; j++){for (int i = 0; i < w; i++){unsigned char tmp = word[i+j*w];for (int k = 0; k < 8; k++){if (tmp & 0x80){draw_point(i*8+k+x, j+y, col);}else{//文字的背景色}tmp = tmp << 1;}}}
}

9.绘制文字库里的单字

int draw_utf8(UTF8_INFO *info, int x, int y, char* zi, unsigned int col, unsigned int col1)
{unsigned long  out = 0 ;int ret = enc_utf8_to_unicode_one((unsigned char*)zi,&out);unsigned char* data = get_utf_data(info,out);unsigned char temp = 0 ;unsigned int i,j,k;unsigned int num = 0;for(i=0;i<info->height;i++){for(j=0;j<info->width/8;j++){temp = data[num++];for(k=0;k<8;k++){if(0x80&temp){draw_point( x+k+j*8, y+i, col);}else{//   draw_point( x+k+j*8, y+i, col1);}temp= temp<<1;}}}return ret;
}

10.绘制文字库里的字符串

int draw_utf8_str(UTF8_INFO *info, int arg_x, int arg_y,  char* zi, unsigned int col, unsigned int col1)
{char* temp = zi;unsigned int x = arg_x ;unsigned int y =  arg_y;while(*temp != '\0'){int ret = draw_utf8(info, x, y, temp, col, col1);x += info->width;if(x > vinf.xres){x = 0;y += info->height;if(y > vinf.yres){y = 0;}}temp += ret;}return 0;
}

二, utf.c

#include "utf.h"/****************************************************************************** 函数名:enc_get_utf8_size* 将一个字符的UTF8编码转换成Unicode(UCS-2和UCS-4)编码.** 参数:*    pInput      指向输入缓冲区, 以UTF-8编码*** 返回值:*    成功则返回该字符的UTF8编码所占用的字节数; 失败则返回0.* 注意事项:无******************************************************************************/
int enc_get_utf8_size(const unsigned char pInput)
{unsigned char c = pInput;// 0xxxxxxx 返回0// 10xxxxxx 不存在// 110xxxxx 返回2// 1110xxxx 返回3// 11110xxx 返回4// 111110xx 返回5// 1111110x 返回6if(c< 0x80) return 0;if(c>=0x80 && c<0xC0) return -1;if(c>=0xC0 && c<0xE0) return 2;if(c>=0xE0 && c<0xF0) return 3;if(c>=0xF0 && c<0xF8) return 4;if(c>=0xF8 && c<0xFC) return 5;if(c>=0xFC) return 6;return -1;
}/****************************************************************************** 函数名:enc_utf8_to_unicode_one* 将一个字符的UTF8编码转换成Unicode(UCS-2和UCS-4)编码.** 参数:*    pInput      指向输入缓冲区, 以UTF-8编码*    Unic        指向输出缓冲区, 其保存的数据即是Unicode编码值,*                类型为unsigned long .** 返回值:*    成功则返回该字符的UTF8编码所占用的字节数; 失败则返回0.** 注意事项:*     1. UTF8没有字节序问题, 但是Unicode有字节序要求;*        字节序分为大端(Big Endian)和小端(Little Endian)两种;*        在Intel处理器中采用小端法表示, 在此采用小端法表示. (低地址存低位)****************************************************************************/
int enc_utf8_to_unicode_one(const unsigned char* pInput, unsigned long *Unic)
{assert(pInput != NULL && Unic != NULL);// b1 表示UTF-8编码的pInput中的高字节, b2 表示次高字节, ...char b1, b2, b3, b4, b5, b6;*Unic = 0x0; // 把 *Unic 初始化为全零int utfbytes = enc_get_utf8_size(*pInput);//int utfbytes = 3;unsigned char *pOutput = (unsigned char *) Unic;switch ( utfbytes ){case 0:*pOutput     = *pInput;utfbytes    += 1;break;case 2:b1 = *pInput;b2 = *(pInput + 1);if ( (b2 & 0xE0) != 0x80 )return 0;*pOutput     = (b1 << 6) + (b2 & 0x3F);*(pOutput+1) = (b1 >> 2) & 0x07;break;case 3:b1 = *pInput;b2 = *(pInput + 1);b3 = *(pInput + 2);if ( ((b2 & 0xC0) != 0x80) || ((b3 & 0xC0) != 0x80) )return 0;*pOutput     = (b2 << 6) + (b3 & 0x3F);*(pOutput+1) = (b1 << 4) + ((b2 >> 2) & 0x0F);break;case 4:b1 = *pInput;b2 = *(pInput + 1);b3 = *(pInput + 2);b4 = *(pInput + 3);if ( ((b2 & 0xC0) != 0x80) || ((b3 & 0xC0) != 0x80)|| ((b4 & 0xC0) != 0x80) )return 0;*pOutput     = (b3 << 6) + (b4 & 0x3F);*(pOutput+1) = (b2 << 4) + ((b3 >> 2) & 0x0F);*(pOutput+2) = ((b1 << 2) & 0x1C)  + ((b2 >> 4) & 0x03);break;case 5:b1 = *pInput;b2 = *(pInput + 1);b3 = *(pInput + 2);b4 = *(pInput + 3);b5 = *(pInput + 4);if ( ((b2 & 0xC0) != 0x80) || ((b3 & 0xC0) != 0x80)|| ((b4 & 0xC0) != 0x80) || ((b5 & 0xC0) != 0x80) )return 0;*pOutput     = (b4 << 6) + (b5 & 0x3F);*(pOutput+1) = (b3 << 4) + ((b4 >> 2) & 0x0F);*(pOutput+2) = (b2 << 2) + ((b3 >> 4) & 0x03);*(pOutput+3) = (b1 << 6);break;case 6:b1 = *pInput;b2 = *(pInput + 1);b3 = *(pInput + 2);b4 = *(pInput + 3);b5 = *(pInput + 4);b6 = *(pInput + 5);if ( ((b2 & 0xC0) != 0x80) || ((b3 & 0xC0) != 0x80)|| ((b4 & 0xC0) != 0x80) || ((b5 & 0xC0) != 0x80)|| ((b6 & 0xC0) != 0x80) )return 0;*pOutput     = (b5 << 6) + (b6 & 0x3F);*(pOutput+1) = (b5 << 4) + ((b6 >> 2) & 0x0F);*(pOutput+2) = (b3 << 2) + ((b4 >> 4) & 0x03);*(pOutput+3) = ((b1 << 6) & 0x40) + (b2 & 0x3F);break;default:return 0;break;}return utfbytes;
}/****************************************************************************** 函数名:enc_unicode_to_utf8_one* 将一个字符的Unicode(UCS-2和UCS-4)编码转换成UTF-8编码.** 参数:*    unic     字符的Unicode编码值*    pOutput  指向输出的用于存储UTF8编码值的缓冲区的指针*    outsize  pOutput缓冲的大小** 返回值:*    返回转换后的字符的UTF8编码所占的字节数, 如果出错则返回 0 .** 注意事项:*     1. UTF8没有字节序问题, 但是Unicode有字节序要求;*        字节序分为大端(Big Endian)和小端(Little Endian)两种;*        在Intel处理器中采用小端法表示, 在此采用小端法表示. (低地址存低位)*     2. 请保证 pOutput 缓冲区有最少有 6 字节的空间大小!****************************************************************************/
int enc_unicode_to_utf8_one(unsigned long unic, unsigned char *pOutput,int outSize){assert(pOutput != NULL);assert(outSize >= 6);if ( unic <= 0x0000007F ){// * U-00000000 - U-0000007F:  0xxxxxxx*pOutput     = (unic & 0x7F);return 1;}else if ( unic >= 0x00000080 && unic <= 0x000007FF ){// * U-00000080 - U-000007FF:  110xxxxx 10xxxxxx*(pOutput+1) = (unic & 0x3F) | 0x80;*pOutput     = ((unic >> 6) & 0x1F) | 0xC0;return 2;}else if ( unic >= 0x00000800 && unic <= 0x0000FFFF ){// * U-00000800 - U-0000FFFF:  1110xxxx 10xxxxxx 10xxxxxx*(pOutput+2) = (unic & 0x3F) | 0x80;*(pOutput+1) = ((unic >>  6) & 0x3F) | 0x80;*pOutput     = ((unic >> 12) & 0x0F) | 0xE0;return 3;}else if ( unic >= 0x00010000 && unic <= 0x001FFFFF ){// * U-00010000 - U-001FFFFF:  11110xxx 10xxxxxx 10xxxxxx 10xxxxxx*(pOutput+3) = (unic & 0x3F) | 0x80;*(pOutput+2) = ((unic >>  6) & 0x3F) | 0x80;*(pOutput+1) = ((unic >> 12) & 0x3F) | 0x80;*pOutput     = ((unic >> 18) & 0x07) | 0xF0;return 4;}else if ( unic >= 0x00200000 && unic <= 0x03FFFFFF ){// * U-00200000 - U-03FFFFFF:  111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx*(pOutput+4) = (unic & 0x3F) | 0x80;*(pOutput+3) = ((unic >>  6) & 0x3F) | 0x80;*(pOutput+2) = ((unic >> 12) & 0x3F) | 0x80;*(pOutput+1) = ((unic >> 18) & 0x3F) | 0x80;*pOutput     = ((unic >> 24) & 0x03) | 0xF8;return 5;}else if ( unic >= 0x04000000 && unic <= 0x7FFFFFFF ){// * U-04000000 - U-7FFFFFFF:  1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx*(pOutput+5) = (unic & 0x3F) | 0x80;*(pOutput+4) = ((unic >>  6) & 0x3F) | 0x80;*(pOutput+3) = ((unic >> 12) & 0x3F) | 0x80;*(pOutput+2) = ((unic >> 18) & 0x3F) | 0x80;*(pOutput+1) = ((unic >> 24) & 0x3F) | 0x80;*pOutput     = ((unic >> 30) & 0x01) | 0xFC;return 6;}return 0;
}/****************************************************************************** 函数名:init_utf8* 将字库文件读取到缓存区** 参数:*    info     缓存区数据结构** 返回值:*    无** 注意事项:*    无*****************************************************************************/
void init_utf8(UTF8_INFO *info)
{int ret = 0 ;int fd = open(info->path,O_RDONLY);if(-1 == fd){exit(1);}struct stat st;ret = stat(info->path,&st);if(-1 == ret){printf("get zi ku file size error");exit(1);}if(NULL == info->g_ziku_data){info->g_ziku_data= malloc(st.st_size);}ret = read(fd,info->g_ziku_data,st.st_size);if(ret<=0){printf("read utf-8 info error!");exit(1);}
//    info->height = heigh;
//    info->width = width;info->zimo_size = st.st_size /65536;close(fd);
}/****************************************************************************** 函数名:uninit_utf8* 回收字模缓存区空间** 参数:*    info     需要回收的字模缓存区** 返回值:*    无** 注意事项:*    无*****************************************************************************/
void uninit_utf8(UTF8_INFO *info)
{free(info->g_ziku_data);
}/****************************************************************************** 函数名:get_utf_data* 根据编号得到字模** 参数:*    info     字模缓存区*    out      字的编码** 返回值:*    字模起点位置** 注意事项:*    无*****************************************************************************/
unsigned char* get_utf_data(UTF8_INFO *info,int out)
{unsigned char* temp =  info->g_ziku_data+out*info->width*info->height/8;return temp;
}

三,头文件

1.frame buffer.h

#ifndef __FRAMEBUFFER_H__
#define __FRAMEBUFFER_H__#include "utf.h"#define RGB888_FMT 32
#define RGB565_FMT 16extern int init_fb(char *devname);
extern void draw_point(int x,int y, unsigned int col);
extern void uninit_fb(int fd);
extern void draw_clear(unsigned int col);extern void draw_h_line(int x, int y, int len, unsigned int col);
extern void draw_s_line(int x, int y, int len, unsigned int col);
extern void draw_rectangle(int x, int y, int w, int h, unsigned int col);
extern void draw_x_line(int x1, int y1, int x2, int y2, unsigned int col);
extern void draw_circle(int x0, int y0, int r, unsigned int col);
extern void draw_bmp(int x, int y, char *picname, int w, int h);
extern void draw_word(int x, int y, unsigned char *word, int w, int h, unsigned int col);
extern int draw_utf8(UTF8_INFO *info, int x, int y, char* zi, unsigned int col, unsigned int col1);
extern int draw_utf8_str(UTF8_INFO *info, int arg_x, int arg_y,  char* zi, unsigned int col, unsigned int col1);#endif

2.utf.h

#ifndef UTF
#define UTF
#ifdef __cplusplus
extern "C"{
#endif
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>
#include <fcntl.h>
#define u8 unsigned char 
#define u16 unsigned short 
#define u32 unsigned int#define ZIKUK_FILE_SMALL "./ziku"
#define ZIKUK_FILE_BIG "./ziku2_w32_h32"
/***字模文件缓存**/
typedef struct
{char path[256];//字模库文件路径unsigned width; //字模宽度unsigned height;//字模高度unsigned zimo_size;//每个字字模字节数unsigned char* g_ziku_data;//字模库文件缓存区
}UTF8_INFO;extern void init_utf8(UTF8_INFO *info);
extern unsigned char *get_utf_data(UTF8_INFO *info,int out);extern void uninit_utf8(UTF8_INFO *info);
extern int enc_utf8_to_unicode_one(const unsigned char* pInput, unsigned long *Unic);
extern int enc_unicode_to_utf8_one(unsigned long unic, unsigned char *pOutput,int outSize);
extern int enc_get_utf8_size(const unsigned char pInput);#ifdef __cplusplus
}
#endif
#endif // UTF

四,主函数

#include <stdio.h>
#include "framebuffer.h"unsigned char pu[24*24/8] = {
/*--  文字:  普  --*/
/*--  仿宋18;  此字体下对应的点阵为:宽x高=24x24   --*/
0x00,0x00,0x00,0x00,0x03,0x00,0x01,0xC3,0x80,0x00,0xE3,0x00,0x00,0x77,0x00,0x00,
0xFF,0xF0,0x0F,0xFF,0xC0,0x00,0x7E,0xE0,0x06,0x7E,0xE0,0x03,0x7F,0xC0,0x03,0xFF,
0x80,0x01,0x7F,0xFC,0x7F,0xFF,0xE0,0x3E,0x00,0x80,0x03,0xFF,0xC0,0x03,0xFF,0xC0,
0x03,0x81,0xC0,0x03,0xFF,0xC0,0x01,0xFF,0x80,0x01,0x81,0x80,0x01,0xFF,0x80,0x03,
0xFF,0x80,0x01,0x81,0x80,0x00,0x00,0x00
};int main(int argc, const char *argv[])
{//初始化utf8字库UTF8_INFO utf8_info;bzero(&utf8_info, sizeof(UTF8_INFO));strcpy(utf8_info.path, ZIKUK_FILE_BIG);utf8_info.width = 32;utf8_info.height = 32;init_utf8(&utf8_info);int fb_fd = init_fb("/dev/fb0");if (-1 == fb_fd){return -1;}draw_point(400, 300, 0x00ff0000);draw_clear(0x00000000);//	draw_rectangle(100,100, 100,200, 0x00ff0000);//draw_x_line(200, 200, 300, 300, 0x0000ffff);//draw_x_line(200, 200, 300, 100, 0x0000ffff);//	draw_x_line(300, 300, 100, 100, 0x00ff00ff);draw_circle(200,200, 200, 0x00ffffff);sleep(2);draw_bmp(0, 0, "./res/1.bmp", 800, 600);//	draw_word(100, 100, pu, 24/8, 24, 0x00ff0000);draw_utf8_str(&utf8_info, 100, 100, "水产品养殖远程监控系统", 0x00ff0000, 0x00ffffff);uninit_fb(fb_fd);return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/879188.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

直播相关02-录制麦克风声音,QT 信号与槽,自定义信号和槽

一 信号与槽函数 #include "mainwindow.h" #include <QPushButton> #include <iostream> using namespace std;//我们的目的是在 window中加入一个button&#xff0c;当点击这个button后&#xff0c;关闭 MainWindow 。 MainWindow::MainWindow(QWidget …

0.3 学习Stm32经历过的磨难

文章目录 用库函数传参 能否按位或STM32库函数XXX_GetFlagStatus和XXX_GetITStatus的区别关于MDK导入文件后报错 Browse information of one files is not available用exti中断读取按键 忘记消抖 &#xff08;更离谱的是&#xff0c;我忘记开启afio的时钟了 Damn!&#xff09;D…

【Lua学习】Lua入门

上一篇帖子【Lua学习】Lua最最基础的 – 经云的清净小站 (skycreator.top)讲了Lua是什么&#xff0c;Lua如何安装在Linux和Windows上。那么安装好之后&#xff0c;我们就要使用Lua实现我们的各种功能了。 首先&#xff0c;我们要先了解Lua一些最基本的内容&#xff0c;比如怎么…

攻防世界 Web_php_unserialize

Web_php_unserialize PHP反序列化 看看代码 <?php class Demo { private $file index.php;public function __construct($file) { $this->file $file; }function __destruct() { echo highlight_file($this->file, true); }function __wakeup() { if ($this->…

【QT】自制一个简单的时钟(跟随系统时间)

目录 源代码&#xff1a; 输出结果如下&#xff1a; 使用QT完成一个简单的时钟图形化界面&#xff0c;功能是完成了时分秒指针能够跟随系统时间移动 设计思路&#xff1a; 1、首先将时钟的边框绘制出来 2、定义出一个定时器t1&#xff0c;将定时器连接到update_slot槽内&#…

supervisor安装CeSi集中化管理Supervisor

一、安装supervisor 备注&#xff1a;supervisor 只能管理前台进程的服务&#xff0c;比如 npm run 这些 &#xff0c;一些后台运行的服务无法管理【后台运行的服务可以用systemd 进行管理】 1、安装epel源 yum install epel-release yum install -y supervisor 2、创建sup…

比较stl库的ostringstream与Qt的QString::arg(),QString::number()

需求&#xff1a; 显示一个float或者double类型的数&#xff0c;要求小数点后的数字位数为定值。 考虑STL库的ostringstream或者Qt的QString::arg(), number 对于stringstream,使用比较繁琐&#xff0c;要联合使用std::fixed和std::setprecision才能实现固定小数位数显示&am…

[论文笔记]QLoRA: Efficient Finetuning of Quantized LLMs

引言 今天带来LoRA的量化版论文笔记——QLoRA: Efficient Finetuning of Quantized LLMs 为了简单&#xff0c;下文中以翻译的口吻记录&#xff0c;比如替换"作者"为"我们"。 我们提出了QLoRA&#xff0c;一种高效的微调方法&#xff0c;它在减少内存使用…

C语言深入理解指针五(18)

文章目录 前言一、回调函数是什么&#xff1f;二、qsort使用举例使用qsort函数排序整型数据使用qsort函数排序结构数据 三、qsort的模拟实现总结 前言 本篇将会很有意思&#xff01; 一、回调函数是什么&#xff1f; 回调函数就是一个通过函数指针调用的函数。   如果你把函数…

C++——STL——栈(stack)

栈的定义 栈 &#xff08; stack &#xff09;是限定仅在表的一端进行插入和删除操作的线性表&#xff0c;允许插入和删除的一端称 为栈顶&#xff0c;另一端称为栈底&#xff0c;不含任何数据元素的栈称为空栈。 栈的示意图 因为栈只能够在一端进行插入和删除&#xff0c;所以…

大数据之Flink(三)

9.3、转换算子 9.3.1、基本转换算子 9.3.1.1、映射map 一一映射 package transform;import bean.WaterSensor; import org.apache.flink.streaming.api.datastream.DataStreamSource; import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator; impor…

鸿蒙交互事件开发04——手势事件

1 概 述 手势事件是移动应用开发中最常见的事件之一&#xff0c;鸿蒙提供了一些方法来绑定手势事件。通过给各个组件绑定不同的手势事件&#xff0c;并设计事件的响应方式&#xff0c;当手势识别成功时&#xff0c;ArkUI框架将通过事件回调通知组件手势识别的结果。 …

王道考研操作系统笔记(一)

虚拟内存的定义和特征&#xff1a; 基于局部性的原理&#xff0c; 在程序装入时&#xff0c;可以将程序中很快用到的部分装入内存&#xff0c;暂时用不到的数据装入外存&#xff0c;就可以让程序开始执行&#xff0c;在程序执行过程中&#xff0c;当所访问的信息不在内存的时…

frida主动调用init_array中的函数

ida打开目标so&#xff0c;查看要主动调用的函数 前提是先过掉检测frida等等&#xff0c;然后控制台启动 输出so地址 Process.findModuleByName("libmod.so") New函数 var aa new NativeFunction(ptr(0x785e002000).add(0x134EC0),"void",[]) 主动调用 a…

如何让人工智能训练更快

影响人工智能训练时间的因素 在深度学习训练中&#xff0c;训练时间的计算涉及到多个因素&#xff0c;包括 epoch 数、全局 batch size、微 batch size、计算设备数量等。下面是一个基本的公式来说明这些参数之间的关系&#xff08;注意&#xff0c;这只是一个基本的说明公式&…

Makefile文件理解

https://zhuanlan.zhihu.com/p/629855009 参考链接 这个链接我没都看&#xff0c;等用的时候再看吧 我遇到的文件是下面这张图片&#xff0c;然后23行两条命令和在命令行中执行是一样的。

E32.【C语言 】练习:蓝桥杯题 懒羊羊字符串

1.题目 【问题描述】 “懒羊羊”字符串是一种特定类型的字符串&#xff0c;它由三个字符组成&#xff0c;具有以下特点: 1.字符串长度为 3. 2.包含两种不同的字母。 3.第二个字符和第三个字符相同 换句话说&#xff0c;“懒羊羊”字符串的形式应为 ABB&#xff0c;其中A和B是不…

k8s 资源管理

文章目录 ResourceQuota什么是资源配额定义一个ResourceQuotaResourceQuota的使用 LimitRangeLimitRange的用途示例1&#xff1a;配置默认的requests和limits 节点故障大部分都是由于资源分配不合理、超额分配引起的&#xff0c;因此需要用某个技术手段保证节点的资源不会过大地…

【HCIA-Datacom】网络参考模型

网络参考模型 1. 应用和数据2. 网络参考模型与标准协议OSI参考模型TCP/IP参考模型与标准协议常见的几种协议应用层传输层网络层和数据链路层物理层 3. 数据通信过程思考题测一测 ⭐在上一章节中已经给大家介绍了我们网络与生活之间的一些联系 ⭐这一章节主要学习的内容叫做网络…

GDB 查看汇编

查看汇编 x disassemble