Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Libpng
提交
76b0459f
T
Third Party Libpng
项目概览
OpenHarmony
/
Third Party Libpng
11 个月 前同步成功
通知
4
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Libpng
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
76b0459f
编写于
11月 16, 2011
作者:
J
John Bowler
提交者:
Glenn Randers-Pehrson
11月 16, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libpng15] Updated contrib/sRGBtables code
上级
ae41dc55
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
187 addition
and
33 deletion
+187
-33
contrib/sRGBtables/cvtcolor.c
contrib/sRGBtables/cvtcolor.c
+181
-0
contrib/sRGBtables/makesRGB.c
contrib/sRGBtables/makesRGB.c
+2
-30
contrib/sRGBtables/sRGB.h
contrib/sRGBtables/sRGB.h
+4
-3
未找到文件。
contrib/sRGBtables/cvtcolor.c
0 → 100644
浏览文件 @
76b0459f
/*-
* convert.c
*
* Convert 8-bit sRGB or 16-bit linear values to another format.
*/
#define _ISOC99_SOURCE 1
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <fenv.h>
#include "sRGB.h"
static
void
usage
(
const
char
*
prog
)
{
fprintf
(
stderr
,
"%s: usage: %s [-linear|-sRGB] [-gray|-color] component{1,4}
\n
"
,
prog
,
prog
);
exit
(
1
);
}
unsigned
long
component
(
const
char
*
prog
,
const
char
*
arg
,
int
issRGB
)
{
char
*
ep
;
unsigned
long
c
=
strtoul
(
arg
,
&
ep
,
0
);
if
(
ep
<=
arg
||
*
ep
||
c
>
65535
||
(
issRGB
&&
c
>
255
))
{
fprintf
(
stderr
,
"%s: %s: invalid component value (%lu)
\n
"
,
prog
,
arg
,
c
);
usage
(
prog
);
}
return
c
;
}
int
main
(
int
argc
,
const
char
**
argv
)
{
const
char
*
prog
=
*
argv
++
;
int
to_linear
=
0
,
to_gray
=
0
,
to_color
=
0
;
int
channels
=
0
;
double
c
[
4
];
/* FE_TONEAREST is the IEEE754 round to nearest, preferring even, mode; i.e.
* everything rounds to the nearest value except that '.5' rounds to the
* nearest even value.
*/
fesetround
(
FE_TONEAREST
);
c
[
3
]
=
c
[
2
]
=
c
[
1
]
=
c
[
0
]
=
0
;
while
(
--
argc
>
0
&&
**
argv
==
'-'
)
{
const
char
*
arg
=
1
+*
argv
++
;
if
(
strcmp
(
arg
,
"sRGB"
)
==
0
)
to_linear
=
0
;
else
if
(
strcmp
(
arg
,
"linear"
)
==
0
)
to_linear
=
1
;
else
if
(
strcmp
(
arg
,
"gray"
)
==
0
)
to_gray
=
1
,
to_color
=
0
;
else
if
(
strcmp
(
arg
,
"color"
)
==
0
)
to_gray
=
0
,
to_color
=
1
;
else
usage
(
prog
);
}
switch
(
argc
)
{
default:
usage
(
prog
);
break
;
case
4
:
c
[
3
]
=
component
(
prog
,
argv
[
3
],
to_linear
);
++
channels
;
case
3
:
c
[
2
]
=
component
(
prog
,
argv
[
2
],
to_linear
);
++
channels
;
case
2
:
c
[
1
]
=
component
(
prog
,
argv
[
1
],
to_linear
);
++
channels
;
case
1
:
c
[
0
]
=
component
(
prog
,
argv
[
0
],
to_linear
);
++
channels
;
break
;
}
if
(
to_linear
)
{
int
i
;
int
components
=
channels
;
if
((
components
&
1
)
==
0
)
--
components
;
for
(
i
=
0
;
i
<
components
;
++
i
)
c
[
i
]
=
linear_from_sRGB
(
c
[
i
]
/
255
);
if
(
components
<
channels
)
c
[
components
]
=
c
[
components
]
/
255
;
}
else
{
int
i
;
for
(
i
=
0
;
i
<
4
;
++
i
)
c
[
i
]
/=
65535
;
if
((
channels
&
1
)
==
0
)
{
double
alpha
=
c
[
channels
-
1
];
if
(
alpha
>
0
)
for
(
i
=
0
;
i
<
channels
-
1
;
++
i
)
c
[
i
]
/=
alpha
;
else
for
(
i
=
0
;
i
<
channels
-
1
;
++
i
)
c
[
i
]
=
1
;
}
}
if
(
to_gray
)
{
if
(
channels
<
3
)
{
fprintf
(
stderr
,
"%s: too few channels (%d) for -gray
\n
"
,
prog
,
channels
);
usage
(
prog
);
}
c
[
0
]
=
YfromRGB
(
c
[
0
],
c
[
1
],
c
[
2
]);
channels
-=
2
;
}
if
(
to_color
)
{
if
(
channels
>
2
)
{
fprintf
(
stderr
,
"%s: too many channels (%d) for -color
\n
"
,
prog
,
channels
);
usage
(
prog
);
}
c
[
3
]
=
c
[
1
];
/* alpha, if present */
c
[
2
]
=
c
[
1
]
=
c
[
0
];
}
if
(
to_linear
)
{
int
i
;
if
((
channels
&
1
)
==
0
)
{
double
alpha
=
c
[
channels
-
1
];
for
(
i
=
0
;
i
<
channels
-
1
;
++
i
)
c
[
i
]
*=
alpha
;
}
for
(
i
=
0
;
i
<
channels
;
++
i
)
c
[
i
]
=
nearbyint
(
c
[
i
]
*
65535
);
}
else
/* to sRGB */
{
int
i
=
(
channels
+
1
)
&~
1
;
while
(
--
i
>=
0
)
c
[
i
]
=
sRGB_from_linear
(
c
[
i
]);
for
(
i
=
0
;
i
<
channels
;
++
i
)
c
[
i
]
=
nearbyint
(
c
[
i
]
*
255
);
}
{
int
i
;
for
(
i
=
0
;
i
<
channels
;
++
i
)
printf
(
" %g"
,
c
[
i
]);
}
printf
(
"
\n
"
);
return
0
;
}
contrib/sRGBtables/makesRGB.c
浏览文件 @
76b0459f
...
...
@@ -23,37 +23,9 @@
/* pngpriv.h includes the definition of 'PNG_sRGB_FROM_LINEAR' which is required
* to verify the actual code.
*/
#include "../pngpriv.h"
#include "../
../
pngpriv.h"
/*
* Utility sRGB calculation functions.
*
* Both routines take and return a floating point value in the range
* 0 to 1.0, doing a calculation according to the sRGB specification.
* (In fact the source of the numbers is the wikipedia article at
* http://en.wikipedia.org/wiki/SRGB .)
*/
double
sRGB_from_linear
(
double
l
)
{
if
(
l
<=
0
.
003130
8
)
l
*=
12
.
92
;
else
l
=
1
.
055
*
pow
(
l
,
1
/
2
.
4
)
-
0
.
055
;
return
l
;
}
double
linear_from_sRGB
(
double
s
)
{
if
(
s
<=
0
.
04045
)
return
s
/
12
.
92
;
else
return
pow
((
s
+
0
.
055
)
/
1
.
055
,
2
.
4
);
}
#include "sRGB.h"
/* The tables are declared 'const' in pngpriv.h, so this redefines the tables to
* be used.
...
...
contrib/sRGBtables/sRGB.h
浏览文件 @
76b0459f
...
...
@@ -4,9 +4,10 @@
* Utility file; not actually a header, this contains definitions of sRGB
* calculation functions for inclusion in those test programs that need them.
*
* All routines take and return a floating point value in the range 0 to 1.0,
* doing a calculation according to the sRGB specification. (In fact the source
* of the numbers is the wikipedia article.)
* All routines take and return a floating point value in the range
* 0 to 1.0, doing a calculation according to the sRGB specification
* (in fact the source of the numbers is the wikipedia article at
* http://en.wikipedia.org/wiki/SRGB).
*/
static
double
sRGB_from_linear
(
double
l
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录