FreeImage Android 移植

本文档介绍了如何将FreeImage静态库成功移植到Android平台,解决在Android应用中找不到库内函数的问题,通过preprocess定义FREEIMAGE_LIB进行配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ubuntu 12.4 目录/home/jsa/share/FreeImage/FreeImage_makefile/FreeImage_3154
1、版本3154
2、添加文件夹missing ,包括头文件和函数swab.h swab.cpp
swab.cpp
#include <stdint.h>
#include <asm/byteorder.h>
static void swab(const void *from, void *to,ssize_t n)
{
   ssize_t i;
   if(n < 0)
   {
    return ;
   }
   for(i = 0 ;i < (n / 2)*2; i += 2)
   {
    *((uint16_t *)to+i) = __arch__swab16(*((uint16_t *)from+i));    
   }
}
swab.h:
#ifndef __SWAB_H_
#define __SWAB_H_
static void swab(const void *from, void *to,ssize_t n);
#endif
3、在gensrclist.sh里添加 missing 目录
DIRLIST="missing “
4、在ndk 下的 /home/jsa/share/android-ndk-r9/platforms/android-18/arch-arm/usr/include/asm 目录下的byteorder.h添加
/*static inline __attribute_const__ __u16 ___arch__swab16(__u16 x) //add by jsa
{
      __u16 __x = (x);

        ((__u16)(

                 (((__u16)(__x) & (__u16)0x00ffU) << 8) |

                 (((__u16)(__x) & (__u16)0xff00U) >> 8) ));
 return __x;

}
#define __arch__swab16(x) ___arch__swab16(x)*/

这一步先可以省掉,如果出现无  __arch__swab16 声明时再加上,这个函数未验证,可用性


更改在dcraw_common.cpp 最上边添加如下代码 解决 swab 函数找不到问题 ,1,2,3步均不用操作了
#include <stdint.h>
#include <asm/byteorder.h>
#define __arch__swab16_my(x)  ({ __u16 __x = (x);   ((__u16)(   (((__u16)(__x) & (__u16)0x00ffU) << 8) | (((__u16)(__x) & (__u16)0xff00U) >> 8) ));  })
static void swab(const void *from, void *to,ssize_t n)
{
   ssize_t i;
   if(n < 0)
   {
 return ;
   }
   for(i = 0 ;i < (n / 2)*2; i += 2)
   {
 *((uint16_t *)to+i) = __arch__swab16_my(*((uint16_t *)from+i));
   }
}

5、ImfHuf.cpp 头文件顺序改为
/*#include <ImfHuf.h>
#include <ImfInt64.h>
#include <ImfAutoArray.h>
#include "Iex.h"
#include <string.h>
#include <assert.h>
#include <algorithm>*/

#include <string.h>
#include <cstring>
#include <algorithm>
#include <ImfHuf.h>
#include <ImfInt64.h>
#include <ImfAutoArray.h>
#include "Iex.h"
#include <assert.h>

6、var_defines.h中添加
#ifdef __ANDROID__ //add by jsa
#include <swab.h>
#endif //end add

7、注释掉LibTIFF4下tif_config.h里的
/* Define to 1 if you have the <search.h> header file. */
//#define HAVE_SEARCH_H 1
8、主要修改Makefile.gnu文件
Makefile.gnu

9、修改完之后执行 source gensrclist.sh 命令
产生Makefile.srcs文件
再执行make 命令

解决使用FreeImage静态库,无法找到库里的函数问题
preprocess 定义FREEIMAGE_LIB

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值