x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
jpeg_io_private.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\gil\extension\io\jpeg_io_private.hpp
旋转
特效
属性
历史版本
/* Copyright 2005-2007 Adobe Systems Incorporated Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). See http://opensource.adobe.com/gil for most recent version including documentation. */ /*************************************************************************************************/ #ifndef GIL_JPEG_IO_PRIVATE_H #define GIL_JPEG_IO_PRIVATE_H /// \file /// \brief Internal support for reading and writing JPEG files /// \author Hailin Jin and Lubomir Bourdev \n /// Adobe Systems Incorporated /// \date 2005-2007 \n Last updated September 24, 2006 #include
#include
#include
#include "../../gil_all.hpp" #include "io_error.hpp" namespace boost { namespace gil { namespace detail { // lbourdev: What is the advantage of having channel and colorspace together? Are there cases where they are interrelated? template
struct jpeg_read_support_private { BOOST_STATIC_CONSTANT(bool,is_supported=false); BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_UNKNOWN); }; template <> struct jpeg_read_support_private
{ BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8); BOOST_STATIC_CONSTANT(bool,is_supported=true); BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_GRAYSCALE); }; template <> struct jpeg_read_support_private
{ BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8); BOOST_STATIC_CONSTANT(bool,is_supported=true); BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_RGB); }; template <> struct jpeg_read_support_private
{ BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8); BOOST_STATIC_CONSTANT(bool,is_supported=true); BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_CMYK); }; template
struct jpeg_write_support_private { BOOST_STATIC_CONSTANT(bool,is_supported=false); BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_UNKNOWN); }; template <> struct jpeg_write_support_private
{ BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8); BOOST_STATIC_CONSTANT(bool,is_supported=true); BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_GRAYSCALE); }; template <> struct jpeg_write_support_private
{ BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8); BOOST_STATIC_CONSTANT(bool,is_supported=true); BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_RGB); }; template <> struct jpeg_write_support_private
{ BOOST_STATIC_ASSERT(BITS_IN_JSAMPLE==8); BOOST_STATIC_CONSTANT(bool,is_supported=true); BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_CMYK); }; class jpeg_reader : public file_mgr { protected: jpeg_decompress_struct _cinfo; jpeg_error_mgr _jerr; void init() { _cinfo.err=jpeg_std_error(&_jerr); jpeg_create_decompress(&_cinfo); jpeg_stdio_src(&_cinfo,_fp.get()); jpeg_read_header(&_cinfo,TRUE); } public: jpeg_reader(FILE* file) : file_mgr(file) { init(); } jpeg_reader(const char* filename) : file_mgr(filename, "rb") { init(); } ~jpeg_reader() { jpeg_destroy_decompress(&_cinfo); } template
void apply(const View& view) { jpeg_start_decompress(&_cinfo); // lbourdev: Can this return an error? You need to check and throw. Check all other library methods that can return an error state... io_error_if(_cinfo.data_precision!=8,"jpeg_reader::apply(): this image file is not supported"); io_error_if(_cinfo.out_color_space!=jpeg_read_support_private
::type, typename color_space_type
::type>::color_type, "jpeg_reader::apply(): input view type does not match the image file"); io_error_if(view.dimensions() != get_dimensions(), "jpeg_reader::apply(): input view dimensions do not match the image file"); std::vector
::type> > > row(view.width()); JSAMPLE* row_address=(JSAMPLE*)&row.front(); for(int y=0;y
void read_image(Image& im) { im.recreate(get_dimensions()); apply(view(im)); } point2
get_dimensions() const { return point2
(_cinfo.image_width,_cinfo.image_height); } }; // This code will be simplified... template
class jpeg_reader_color_convert : public jpeg_reader { private: CC _cc; public: jpeg_reader_color_convert(FILE* file,CC cc_in) : jpeg_reader(file),_cc(cc_in) {} jpeg_reader_color_convert(FILE* file) : jpeg_reader(file) {} jpeg_reader_color_convert(const char* filename,CC cc_in) : jpeg_reader(filename),_cc(cc_in) {} jpeg_reader_color_convert(const char* filename) : jpeg_reader(filename) {} template
void apply(const View& view) { jpeg_start_decompress(&_cinfo); // lbourdev: Can this return an error? You need to check and throw. Check all other library methods that can return an error state... io_error_if(_cinfo.data_precision!=8,"jpeg_reader_color_covert::apply(): this image file is not supported"); io_error_if(view.dimensions() != get_dimensions(), "jpeg_reader_color_covert::apply(): input view dimensions don't match the image file"); switch (_cinfo.out_color_space) { case JCS_GRAYSCALE: { std::vector
row(view.width()); JSAMPLE* row_address=(JSAMPLE*)&row.front(); for(int y=0;y
(_cc)); } break; } case JCS_RGB: { std::vector
row(view.width()); JSAMPLE* row_address=(JSAMPLE*)&row.front(); for(int y=0;y
(_cc)); } break; } case JCS_CMYK: { std::vector
row(view.width()); JSAMPLE* row_address=(JSAMPLE*)&row.front(); for(int y=0;y
(_cc)); } break; } default: io_error("jpeg_reader_color_covert::apply(): unknown color type"); } jpeg_finish_decompress(&_cinfo); } template
void read_image(Image& im) { im.recreate(get_dimensions()); apply(view(im)); } }; class jpeg_writer : public file_mgr { jpeg_compress_struct _cinfo; jpeg_error_mgr _jerr; void init() { _cinfo.err=jpeg_std_error(&_jerr); jpeg_create_compress(&_cinfo); jpeg_stdio_dest(&_cinfo,_fp.get()); } public: jpeg_writer(FILE* file) : file_mgr(file) { init(); } jpeg_writer(const char* filename) : file_mgr(filename, "wb") { init(); } ~jpeg_writer() { jpeg_destroy_compress(&_cinfo); } template
void apply(const View& view,int quality=100) { _cinfo.image_width = (JDIMENSION)view.width(); _cinfo.image_height = (JDIMENSION)view.height(); _cinfo.input_components=num_channels
::value; _cinfo.in_color_space = jpeg_write_support_private
::type, typename color_space_type
::type>::color_type; jpeg_set_defaults(&_cinfo); jpeg_set_quality(&_cinfo, quality, TRUE); jpeg_start_compress(&_cinfo, TRUE); std::vector
::type> > > row(view.width()); JSAMPLE* row_address=(JSAMPLE*)&row.front(); for (int y=0;y
jpeg_io_private.hpp
网页地址
文件地址
上一页
5/10
下一页
下载
( 9 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.