当我尝试构建此代码时,行struct my_error_mgr jerr;
会出现错误“变量类型不完整'struct my_error_mgr'
#import "Engine.h"
#include "jpeglib.h"
@implementation Engine
+(void)test{
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
FILE * infile;
if ((infile = fopen(filename, "rb")) == NULL) {
fprintf(stderr, "can't open %s\n", filename);
return 0;
}
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
if (setjmp(jerr.setjmp_buffer)) {
jpeg_destroy_decompress(&cinfo);
fclose(infile);
return 0;
}
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, infile);
(void) jpeg_read_header(&cinfo, TRUE);
jvirt_barray_ptr* coeffs_array;
coeffs_array = jpeg_read_coefficients(&cinfo);
BOOL done = FALSE;
for (int ci = 0; ci < 3; ci++)
{
JBLOCKARRAY buffer_one;
JCOEFPTR blockptr_one;
jpeg_component_info* compptr_one;
compptr_one = cinfo.comp_info + ci;
for (int by = 0; by < compptr_one->height_in_blocks; by++)
{
buffer_one = (cinfo.mem->access_virt_barray)((j_common_ptr)&cinfo, coeffs_array[ci], by, (JDIMENSION)1, FALSE);
for (int bx = 0; bx < compptr_one->width_in_blocks; bx++)
{
blockptr_one = buffer_one[0][bx];
for (int bi = 0; bi < 64; bi++)
{
blockptr_one[bi]++;
}
}
}
}
write_jpeg(output, &cinfo, coeffs_array); // saving modified JPEG to the output file
jpeg_destroy_decompress(&cinfo);
fclose(infile);
}
@end
当我尝试注释掉与此错误相关的所有行时,我在行上得到EXC_BAD_ACCESS
运行时错误
(void) jpeg_read_header(&cinfo, infile);
我正在尝试修改iOS中保存的JPEG图像的DCT系数,最终目标是创建JPEG隐写应用程序。我有以下代码尝试在每个DCT系数中添加一个。我正在使用libjpeg库。代码是Objective-C和C的组合。
快速说明,变量文件名等于“/ Users / ScottBouloutian / Library / Application Support / iPhone Simulator / 7.0.3 / Applications / 27A0450E-4685-4C3E-AAC8-A0CC6C85359E / Crypsis.app / screen.jpg “,这是我试图修改的JPEG图像的路径。
我的代码有什么问题?是不是像我的文件路径缺少包含或出错了?
答案 0 :(得分:5)
无论struct my_error_mgr
是什么,编译器都无法将其声明作为类型找到。您需要包含具有该声明的标头。
答案 1 :(得分:2)
我的代码中出现以下错误:
Variable has incomplete type 'RCTLayoutMetrics' (aka 'struct CG_BOXABLE')
我升级到Xcode版本9.2(9C40b)并解决了这个问题。