資源簡介
使用 OpenCL 采樣器對象,從原始圖像中截取部分矩形區域。
代碼片段和文件信息
#include?
#include?
#ifdef?__APPLE__
#include?
#else
#include?
#endif
#include?“util.h“
extern?void?scissor(uint8_t?*src?uint8_t?*des?int?orig_width?int?orig_height
int?new_width?int?new_height);
int?main()
{
/*?RGBA?image?format?*/
uint?orig_width?=?512
?????orig_height?=?512
?????size?=?orig_width?*?orig_height?*?4;
uint?new_width?=?256
?????new_height?=?256;
uint8_t?*img_buffer;
uint8_t?*out_buffer;
//?1.定義輸入文件和輸出文件
const?char?*img_file?=?“/data/local/tmp/lenna_rgba.bin“;
const?char?*out_file?=?“lenna_rgba_target.bin“;
//?2.分別為兩個文件預分配緩沖區
img_buffer?=?(uint8_t?*)malloc(size);
out_buffer?=?(uint8_t?*)malloc(size);
if?(!img_buffer?||?!out_buffer)?{
perror(“malloc?memory?fail“);
exit(EXIT_FAILURE);
}
//?3.將輸入文件保存到緩沖區中
load_data(img_file?img_buffer?size);
//?4.旋轉圖像
scissor(img_buffer?out_buffer?orig_width?orig_height
new_width?new_height);
//?5.把旋轉后的圖像數據保存到輸出文件中
store_data(out_file?out_buffer?384?*?384?*?4);
//?6.釋放緩沖區
free(img_buffer);
free(out_buffer);
return?0;
}
- 上一篇:S3C2440全面實用原理圖
- 下一篇:ADRecycleBin1.2
評論
共有 條評論