Ejemplo n.º 1
0
uint8_t* ImageDecoder::decodeJPEG(uint8_t* inData, int len, const uint8_t* tablesData, int tablesLen, uint32_t* width, uint32_t* height, bool* hasAlpha)
{
	struct source_mgr src(inData,len);

	src.init_source = init_source;
	src.fill_input_buffer = fill_input_buffer;
	src.skip_input_data = skip_input_data;
	src.resync_to_restart = resync_to_restart;
	src.term_source = term_source;

	struct source_mgr *tablesSrc;
	if (tablesData)
	{
		tablesSrc = new source_mgr(tablesData,tablesLen);

		tablesSrc->init_source = init_source;
		tablesSrc->fill_input_buffer = fill_input_buffer;
		tablesSrc->skip_input_data = skip_input_data;
		tablesSrc->resync_to_restart = resync_to_restart;
		tablesSrc->term_source = term_source;
	}
	else
	{
		tablesSrc = NULL;
	}

	uint8_t* decoded = decodeJPEGImpl(&src, tablesSrc, width, height, hasAlpha);
	delete tablesSrc;
	return decoded;
}
Ejemplo n.º 2
0
uint8_t* ImageDecoder::decodeJPEG(uint8_t* inData, int len, uint32_t* width, uint32_t* height)
{
	struct source_mgr src(inData,len);

	src.init_source = init_source;
	src.fill_input_buffer = fill_input_buffer;
	src.skip_input_data = skip_input_data;
	src.resync_to_restart = resync_to_restart;
	src.term_source = term_source;

	return decodeJPEGImpl(src, width, height);
}
Ejemplo n.º 3
0
uint8_t* ImageDecoder::decodeJPEG(std::istream& str, uint32_t* width, uint32_t* height)
{
	struct istream_source_mgr src(str);

	src.capacity=4096;
	src.data=new char[src.capacity];
	src.init_source = init_source_istream;
	src.fill_input_buffer = fill_input_buffer_istream;
	src.skip_input_data = skip_input_data_istream;
	src.resync_to_restart = jpeg_resync_to_restart;
	src.term_source = term_source;

	uint8_t* res=decodeJPEGImpl(src, width, height);

	delete[] src.data;
	return res;
}
Ejemplo n.º 4
0
uint8_t* ImageDecoder::decodeJPEG(uint8_t* inData, int len, const uint8_t* tablesData, int tablesLen, uint32_t* width, uint32_t* height, bool* hasAlpha)
{
	struct jpeg_source_mgr src;

	src.next_input_byte = (const JOCTET*)inData;
	src.bytes_in_buffer = len;
	src.init_source = init_source_nop;
	src.fill_input_buffer = fill_input_buffer;
	src.skip_input_data = skip_input_data;
	src.resync_to_restart = resync_to_restart;
	src.term_source = term_source;

	struct jpeg_source_mgr *tablesSrc;
	if (tablesData)
	{
		tablesSrc = new jpeg_source_mgr();

		tablesSrc->next_input_byte = (const JOCTET*)tablesData;
		tablesSrc->bytes_in_buffer = tablesLen;
		tablesSrc->init_source = init_source_nop;
		tablesSrc->fill_input_buffer = fill_input_buffer;
		tablesSrc->skip_input_data = skip_input_data;
		tablesSrc->resync_to_restart = resync_to_restart;
		tablesSrc->term_source = term_source;
	}
	else
	{
		tablesSrc = NULL;
	}

	*width = 0;
	*height = 0;
	uint8_t* decoded = decodeJPEGImpl(&src, tablesSrc, width, height, hasAlpha);
	delete tablesSrc;
	return decoded;
}