1 Star 0 Fork 27

Zhouyj/third_party_libjpeg-turbo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cmyk.h 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
DRC 提交于 2018-03-08 10:55 . Improve code formatting consistency
/*
* cmyk.h
*
* Copyright (C) 2017-2018, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains convenience functions for performing quick & dirty
* CMYK<->RGB conversion. This algorithm is suitable for testing purposes
* only. Properly converting between CMYK and RGB requires a color management
* system.
*/
#ifndef CMYK_H
#define CMYK_H
#include <jinclude.h>
#define JPEG_INTERNALS
#include <jpeglib.h>
#include "jconfigint.h"
/* Fully reversible */
INLINE
LOCAL(void)
rgb_to_cmyk(JSAMPLE r, JSAMPLE g, JSAMPLE b, JSAMPLE *c, JSAMPLE *m,
JSAMPLE *y, JSAMPLE *k)
{
double ctmp = 1.0 - ((double)r / 255.0);
double mtmp = 1.0 - ((double)g / 255.0);
double ytmp = 1.0 - ((double)b / 255.0);
double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
else {
ctmp = (ctmp - ktmp) / (1.0 - ktmp);
mtmp = (mtmp - ktmp) / (1.0 - ktmp);
ytmp = (ytmp - ktmp) / (1.0 - ktmp);
}
*c = (JSAMPLE)(255.0 - ctmp * 255.0 + 0.5);
*m = (JSAMPLE)(255.0 - mtmp * 255.0 + 0.5);
*y = (JSAMPLE)(255.0 - ytmp * 255.0 + 0.5);
*k = (JSAMPLE)(255.0 - ktmp * 255.0 + 0.5);
}
/* Fully reversible only for C/M/Y/K values generated with rgb_to_cmyk() */
INLINE
LOCAL(void)
cmyk_to_rgb(JSAMPLE c, JSAMPLE m, JSAMPLE y, JSAMPLE k, JSAMPLE *r, JSAMPLE *g,
JSAMPLE *b)
{
*r = (JSAMPLE)((double)c * (double)k / 255.0 + 0.5);
*g = (JSAMPLE)((double)m * (double)k / 255.0 + 0.5);
*b = (JSAMPLE)((double)y * (double)k / 255.0 + 0.5);
}
#endif /* CMYK_H */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Zhouyj_zju/third_party_libjpeg-turbo.git
[email protected]:Zhouyj_zju/third_party_libjpeg-turbo.git
Zhouyj_zju
third_party_libjpeg-turbo
third_party_libjpeg-turbo
master

搜索帮助