Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
0a7f094e
O
OpenCorePKG_MOD
项目概览
btwise
/
OpenCorePKG_MOD
通知
26
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OpenCorePKG_MOD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0a7f094e
编写于
5月 28, 2020
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Utilities: Improve Windows compaitiblity for disklabel
上级
a6f7af89
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
44 deletion
+56
-44
Utilities/disklabel/disklabel.c
Utilities/disklabel/disklabel.c
+56
-44
未找到文件。
Utilities/disklabel/disklabel.c
浏览文件 @
0a7f094e
...
...
@@ -19,38 +19,29 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define BigEndianToNative16(x) __builtin_bswap16(x)
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define BigEndianToNative16(x) (x)
#else
#include <arpa/inet.h>
#define BigEndianToNative16(x) ntohs(x)
#endif
#if
def __APPLE__
#if
defined(__APPLE__)
#include <ApplicationServices/ApplicationServices.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#elif defined(WIN32) && !defined(_ISOC99_SOURCE)
#define _ISOC99_SOURCE
#endif // __APPLE__
/* Antialiasing clut. */
static
const
uint8_t
clut
[]
=
{
0x00
,
/* 0x00 0x00 0x00 white */
0xF6
,
/* 0x11 0x11 0x11 */
0xF7
,
/* 0x22 0x22 0x22 */
0x2A
,
/* 0x33 = 1*6^2 + 1*6 + 1 = 43 colors */
0xF8
,
/* 0x44 */
0xF9
,
/* 0x55 */
0x55
,
/* 0x66 = 2*(36 + 6 + 1) = 86 colors */
0xFA
,
/* 0x77 */
0xFB
,
/* 0x88 */
0x80
,
/* 0x99 = (3*43) = 129 colors*/
0xFC
,
/* 0xAA */
0xFD
,
/* 0xBB */
0xAB
,
/* 0xCC = 4*43 = 172 colors */
0xFE
,
/* 0xDD */
0xFF
,
/* 0xEE */
0xD6
,
/* 0xFF = 5*43 = 215 */
};
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
/* Reverse clut to pixels. */
static
const
uint8_t
palette
[
256
]
=
{
...
...
@@ -88,6 +79,27 @@ typedef struct DiskLabel_ {
#pragma pack(pop)
#ifdef __APPLE__
/* Antialiasing clut. */
static
const
uint8_t
clut
[]
=
{
0x00
,
/* 0x00 0x00 0x00 white */
0xF6
,
/* 0x11 0x11 0x11 */
0xF7
,
/* 0x22 0x22 0x22 */
0x2A
,
/* 0x33 = 1*6^2 + 1*6 + 1 = 43 colors */
0xF8
,
/* 0x44 */
0xF9
,
/* 0x55 */
0x55
,
/* 0x66 = 2*(36 + 6 + 1) = 86 colors */
0xFA
,
/* 0x77 */
0xFB
,
/* 0x88 */
0x80
,
/* 0x99 = (3*43) = 129 colors*/
0xFC
,
/* 0xAA */
0xFD
,
/* 0xBB */
0xAB
,
/* 0xCC = 4*43 = 172 colors */
0xFE
,
/* 0xDD */
0xFF
,
/* 0xEE */
0xD6
,
/* 0xFF = 5*43 = 215 */
};
static
CTLineRef
create_text_line
(
CGColorSpaceRef
color_space
,
const
char
*
str
,
int
scale
)
{
/* White text on black background, originating from OF/EFI bitmap. */
const
CGFloat
components
[]
=
{
...
...
@@ -223,6 +235,23 @@ static void *make_label(const char *label, int scale, bool bgra, uint16_t *label
return
label_data
;
}
static
int
write_file
(
const
char
*
filename
,
uint8_t
*
buffer
,
size_t
size
)
{
FILE
*
fh
=
fopen
(
filename
,
"wb+"
);
if
(
!
fh
)
{
fprintf
(
stderr
,
"Cannot open file %s for writing!
\n
"
,
filename
);
return
-
1
;
}
if
(
fwrite
(
buffer
,
size
,
1
,
fh
)
!=
1
)
{
fprintf
(
stderr
,
"Cannot write %zu bytes in %s!
\n
"
,
size
,
filename
);
fclose
(
fh
);
return
-
1
;
}
fclose
(
fh
);
return
0
;
}
#endif // __APPLE__
static
int
read_file
(
const
char
*
filename
,
uint8_t
**
buffer
,
size_t
*
size
)
{
...
...
@@ -272,23 +301,6 @@ static int read_file(const char *filename, uint8_t **buffer, size_t *size) {
return
0
;
}
static
int
write_file
(
const
char
*
filename
,
uint8_t
*
buffer
,
size_t
size
)
{
FILE
*
fh
=
fopen
(
filename
,
"wb+"
);
if
(
!
fh
)
{
fprintf
(
stderr
,
"Cannot open file %s for writing!
\n
"
,
filename
);
return
-
1
;
}
if
(
fwrite
(
buffer
,
size
,
1
,
fh
)
!=
1
)
{
fprintf
(
stderr
,
"Cannot write %zu bytes in %s!
\n
"
,
size
,
filename
);
fclose
(
fh
);
return
-
1
;
}
fclose
(
fh
);
return
0
;
}
static
int
write_ppm
(
const
char
*
filename
,
size_t
width
,
size_t
height
,
uint8_t
*
pixel
,
bool
bgra
)
{
FILE
*
fh
=
fopen
(
filename
,
"wb"
);
if
(
!
fh
)
{
...
...
@@ -352,8 +364,8 @@ static int decode_label(const char *infile, const char *outfile) {
return
-
1
;
}
size_t
width
=
ntohs
(
label
->
width
);
size_t
height
=
ntohs
(
label
->
height
);
size_t
width
=
BigEndianToNative16
(
label
->
width
);
size_t
height
=
BigEndianToNative16
(
label
->
height
);
size_t
exp_size
=
width
*
height
;
bool
bgra
=
label
->
type
==
LABEL_TYPE_BGRA
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录