- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
关于带有 alpha channel 的 JPEG 是否有效似乎存在一些争论。我一直认为正确的答案是 that in the JPEG FAQ ,本质上是“否”。 (这在 another question on Stack Overflow 中得到重申。)
但是,Sun 的 ImageIO 库中的 Java JPEGImageWriter 将愉快地使用 alpha channel 写入和读取灰度和 RGB 图像,即使到目前为止我在 Linux 上几乎没有尝试过可以正确加载此类 JPEG 的应用程序。这在过去被报告为错误,但 Sun 的回应是 these are valid files :
This is not an Image I/O bug, but rather a deficiency in the other applications the submitter mentions. The IIO JPEGImageWriter is able to write images with a color model that contains an alpha channel (referred to in the IJG native source code as the "NIFTY" color spaces, such as RGBA, YCbCrA, etc.), but many applications are not aware of these color spaces. So even though these images written by the IIO JPEG writer are compliant with the JPEG specification (which is blind to the various color space possiblities), some applications may not recognize color spaces that contain an alpha channel and may throw an error or render a corrupted image, as the submitter describes.
Developers wishing to maintain compatibility with these other alpha-unaware applications should write images that do not contain an alpha channel (such as TYPE_INT_RGB). Developers who want the capability of writing/reading an image containing an alpha channel in the JPEG format can do so using the Image I/O API, but need to be aware that many native applications out there are not quite compliant with the YCbCrA and RGBA formats.
For more information, see the Image I/O JPEG Metadata Format Specification and Usage Notes: http://java.sun.com/j2se/1.4.1/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html
Closing as "not a bug". xxxxx@xxxxx 2003-03-24
我正在使用创建此类文件的 Java 应用程序,并希望编写一些 C 代码来尽快加载这些文件。 (本质上,问题在于 Java ImageIO 库在解压缩这些文件时速度非常慢,我们希望通过 JNI 将加载器替换为 native 代码以改善这一点——目前这是一个性能瓶颈。)
此处有一些示例文件 - 向 coulrophobic 的任何人致歉:
在这里你可以看到尝试使用各种 Linux 软件查看灰度 + alpha 和 RGB + alpha 图像的结果,我相信这些软件使用 libjpeg
:
(来源:mark at mythic-beasts.com)
因此,在每种情况下,颜色空间似乎都被误解了。 jpeglib.h
中唯一允许的值是:
/* Known color spaces. */
typedef enum {
JCS_UNKNOWN, /* error/unspecified */
JCS_GRAYSCALE, /* monochrome */
JCS_RGB, /* red/green/blue */
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
JCS_CMYK, /* C/M/Y/K */
JCS_YCCK /* Y/Cb/Cr/K */
} J_COLOR_SPACE;
...这看起来不太乐观。
如果我使用来自 libjpeg
的 example.c
的稍微修改版本加载这些图像,cinfo.jpeg_color_space
和 cinfo.out_color_space
读取header后每张图片如下:
gray-normal.jpg: jpeg_color_space is JCS_GRAYSCALE, out_color_space is JCS_GRAYSCALE
gray-alpha.jpg: jpeg_color_space is JCS_CMYK, out_color_space is JCS_CMYK
rgb-normal.jpg: jpeg_color_space is JCS_YCbCr, out_color_space is JCS_RGB
rgb-alpha.jpg: jpeg_color_space is JCS_CMYK, out_color_space is JCS_CMYK
所以,我的问题是:
显然,对于更普遍的问题,至少还有两个其他解决方案:
...但是第一个会涉及大量的代码更改,并且不清楚如何处理后者。无论如何,我认为如何使用 libjpeg
加载此类文件的问题可能会引起更普遍的兴趣。
如有任何建议,我们将不胜感激。
最佳答案
即使您将图像存储为 4 channel jpeg 图像,我也没有知道如何在 jpeg 文件中指定颜色格式的标准化方法。
JFIF 标准采用 YCbCr。
关于java - 我可以使用 libjpeg 读取带有 alpha channel 的 JPEG 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6212897/
我的目的是使用 libjpeg-turbo (参见 http://www.libjpeg-turbo.org/Main/HomePage )作为独立 Jpeg Group ( http://www.i
当使用 libjpeg 将图像输入 OpenCL 时,为了能够将 channel 视为具有 CL_UNORM_INT8(在 [0.0, 1.0] 范围内 float )的规范化 uint8,您只能用
在我的 C 程序中,我想使用 libexif 和 libjpeg 在给定路径 inputFilePath,并将生成的 jpeg 保存到输出路径 outputFilePath。 输入的 jpeg 文件很
如标题所示,我使用 AWS EC2 和 AWS linux AMI 来设置运行神经式算法的环境。 Nerual-style 我已经成功安装了 torch、Lua、Loadcaffe、Google Pr
如果可能的话,我想使用 libjpeg 从 JPEG 图像的中间读取一行而不读取前面的所有行。这能做到吗? 最佳答案 答案几乎肯定是“是的,你可以,但它需要比你想要的更多的努力”。 JPEG 图像是标
我想使用 libjpeg 库将图像保存到内存( vector )中。我发现那里有功能: init_destination empty_output_buffer term_destination 我的
我正在使用 libjpeg 解码 jpeg 文件。在解码大图像时,用户可能会切换到另一个 jpeg 文件,那么 libjpeg 是否支持解码中断?非常感谢! 最佳答案 Libjpeg 有一个 I/O
我大部分时间都在使用该示例,它确实创建了一个只是乱码的图像: unsigned char* readJpeg(JNIEnv* env, libraw_processed_image_t *raw) {
我使用来自 Independent JPEG Group 的 jpeg 库 v8d我想改变 jpeg 解压缩读取和处理数据的方式。 在 djpeg main() 中,在每个 jpeg_read_sca
来自 jmorecfg.h : #define PACK_TWO_PIXELS(l,r) ((r>16; \ } while(0) #define WRITE_TWO_ALIGNED
我无法理解我从以下代码中得到的段错误: #include #include #include int main(int argc, char** argv){ FILE*
我正在尝试使用 ijg 的 libjpeg 将 RGB 图像压缩为 JPEG。最后的想法是使用图像传感器拍摄图像并将数据压缩为 ARM Cortex M3 Controller 上的 JPEG;但是,
所以我一直在阅读 libjpeg 文档,它非常乏善可陈。 我一直在尝试弄清楚如何从自定义内存缓冲区而不是文件中读取数据,但我不确定如何测试我的解决方案是否正常工作。 目前我从内存中加载 jpeg 的函
我有下一个基于 libjpeg 的 JPEG 图像解压缩标准代码。 jpeg_decompress_struct cinfo; // ...Set error manager and data sou
我正在尝试使用mingw-w64编译libjpeg(版本8d)。我启动的命令是: MyS.BAT /配置 制作 在第三步,我得到这个错误: $ make D:/Builder/bin/make al
我有这样一个常用的代码: struct jpeg_decompress_struct cinfo; jpeg_create_decompress(&cinfo); jpeg_stdio_src(&ci
我正在尝试使用 libjpeg 将图像从一个文件复制到另一个文件。我尝试使用 jpeg_read_scanlines/jpeg_write_scanlines 来复制图像数据,但据我所知这些函数计算
我已经创建了自己的 DCT 计算。 如何使用 jpeg_write_coefficients 将我的 64 个 DCT 值写入使用 jpeg_write_coefficients 的 JPEG 文件(
libjpeg 是否允许/具有缩放输出图像的例程? 我有一个图像需要在保存和加载时调整大小,在输入上提供 width1、height1 并在输出上获取 width2、height2,我真的不能在外面使
我正在使用 C++ JPEG 库 (libjpeg),我意识到当某些函数失败时会调用 exit() 并关闭应用程序。如何覆盖此行为并防止应用程序因 libjpeg 错误而关闭? 最佳答案 这是 lib
我是一名优秀的程序员,十分优秀!