当前位置:网站首页>Expert C Programming Chapter 8 Why Programmers Can't Tell the Difference Between Halloween and Christmas 8.2 Building Graphics from Bit Patterns
Expert C Programming Chapter 8 Why Programmers Can't Tell the Difference Between Halloween and Christmas 8.2 Building Graphics from Bit Patterns
2022-08-07 14:36:00 【weixin_Guest time】
Building Graphics from Bit Patterns
An icon or glyph is an image that is produced by mapping a small bit pattern to the screen.A bit represents a pixel on an image.If a bit is set, the pixel it represents is "bright", and if a bit is cleared, the pixel it represents is "dark".So a series of integer values can be used to encode graphics.Tools like Iconedit are used to draw graphics.The file they output is an ASCII file containing a series of integers that can be included by a windowing program.The problem with it is that the icon in the program is just a string of hexadecimal numbers.In C, a typical 16*16 black and white graphic might look like this:
static unsigned short stopwatch[] = {
0x07C6,
0x1FF7,
0x383B,
0x600C,
0x600C,
0xC006,
0xDF06,
0xC106,
0xC106,
0x610C,
0x610C,
0x3838,
0x1FF0,
0x0700,
0x0000any clues.Here's an amazingly elegant collection of #defines that allow programs to build constants that look like graphics on the screen.
#define X )*2+1
#define - )*2
#define s ((((((((((((((((0 /* used to create 16 bits)Wide graphics*/
After they are defined, the program will automatically create their hexadecimal mode as long as the required icons or graphics are drawn.
Using these macro definitions, the word description ability of the program is greatly enhanced, the above example can be transformed into:
static unsigned short stopwatch[] = {
}
与前面的代码相比,它的意思更为明显。
Standard C has octal, decimal, and hexadecimal constants, but no binary constants, otherwise an easier way to draw graphics bit patterns.
Don't forget to clear these macro definitions after drawing, otherwise it may have unpredictable consequences for your code behind.
边栏推荐
猜你喜欢

C专家编程 第8章 为什么程序员无法分清万圣节和圣诞节 8.7 用C语言实现有限状态机

QT—状态机框架

001_微服务框架学习分类总结

移相带来的振荡器
![[YOLOv7] Combined with GradCAM heat map visualization](/img/99/75523949326c8f1cbeda361c00e60a.jpg)
[YOLOv7] Combined with GradCAM heat map visualization

国内软件测试岗,可以卷到什么程度?

怎么简单实现菜单拖拽排序的功能

MySQL: Calculate shortest distance between latitude and longitude using custom function

C专家编程 第8章 为什么程序员无法分清万圣节和圣诞节 8.5 原型在什么地方会失败

up to date!A summary of all Kaggle competition open source solutions and Top ideas, a total of 477 competitions!
随机推荐
联盛德W801系列1-flash保存数据例程:保存wifi配网信息
HJ3 明明的随机数
C专家编程 第8章 为什么程序员无法分清万圣节和圣诞节 8.7 用C语言实现有限状态机
[YOLOv7_0.1] Network structure and source code analysis
A character occurrences HJ2 calculation
The sword refers to Offer | Adjust the order of the array so that the odd numbers come before the even numbers
ZCMU--2126: Minute thoughts
The solution to the view that the view is clipped and displayed incompletely in any inheritance hierarchy of SwiftUI
桥接模式:Swift 实现
Visual Studio 自定义项目模板
处理乱码的问题oracle字符集WE8MSWIN1252和WE8ISO8859P1
003_服务拆分和远程调用【注册RestTemplate】
mysql database source command to import sql file records
雷达的分辨率
C语言文件输入输出(12)
QT—状态机框架
C专家编程 第8章 为什么程序员无法分清万圣节和圣诞节 8.9 如何进行强制类型转换,为何要进行类型强制转换
修改mysql 数据表主键
C专家编程 第7章 对内存的思考 7.8 轻松一下---“Thing King”和“页面游戏”
d浮点小问题