【问题标题】:Any APIs or code to Convert Raw Image (like DNG) to JPG format in Java/Android在 Java/Android 中将原始图像(如 DNG)转换为 JPG 格式的任何 API 或代码
【发布时间】:2014-05-27 04:19:29
【问题描述】:

我希望使用 Android 将原始图像数据(如 .DNG 扩展名)转换为 JPG 格式。 Playstore中有类似的应用

Raw Decoder Free

谁能给我一些线索或任何开源代码来做同样的事情。

[编辑] 我已经使用 Visual C++ 尝试过THIS 并且能够开发适用于 Windows 操作系统的应用程序。

我正在寻找 Android 的东西。

【问题讨论】:

  • 考虑到应用程序已经做到了,我可以保证某处有这样的 API 或库。到目前为止,您尝试过什么?
  • 我已经尝试libraw.org 使用 VC++ 并且运行良好。
  • 似乎大多数相机原始文件 1) 是某种 TIFF/Exif 衍生文件,并且 b) 包含 JPEG。因此,如果您可以解析 TIFF,那么提取该 JPEG 应该很容易。如果您想获得真正的 RAW 数据以进行进一步处理,则需要做更多的工作,但仍然可行。这是一个很好的来源:lclevy.free.fr

标签: java android image jpeg


【解决方案1】:

您可以使用原始图像中的位图。

为此,您可以将每个字节扩展为 32 位 ARGB int。 A 是 alpha 0xff,R G B 是像素值。 试试下面的代码。 Source 是原始图像的字节数组。

byte [] Source; //Comes from somewhere...
byte [] Bits = new byte[Source.length*4]; //That's where the ARGB array goes.
int i;
for(i=0;i<Source.length;i++)
{
    Bits[i*4] =
        Bits[i*4+1] =
        Bits[i*4+2] = ~Source[i]; //Invert the source bits
    Bits[i*4+3] = -1;//0xff, that's the alpha.
}

//Now put these nice ARGB pixels into a Bitmap object

Bitmap bm = Bitmap.createBitmap(Width, Height, Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(ByteBuffer.wrap(Bits));

或库可用here。但是你需要使用 ndk 来做同样的事情。

【讨论】:

    猜你喜欢
    • 2011-06-04
    • 2023-03-14
    • 2015-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-01
    • 2018-08-26
    • 2019-08-14
    相关资源
    最近更新 更多