DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
True Drop Box
FTP/SFTP Hosting
Group Account
Team Anywhere
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Cloud-to-Cloud Backup
|
DVR/Camera Backup
FTP, Email & Web Service
FTP/SFTP Hosting
|
Email Hosting
|
Web Hosting
|
Webcam Hosting
Other Products & Services
Team Anywhere
|
Connect to Remote PC
|
Cloud Surveillance
|
Virtual CCTV NVR
Quick Links
Security and Privacy
Customer Support
Service Manual
Use Cases
Group Account
Online Help
Support Forum
Contact Us
About DriveHQ
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
Other Features
Team Anywhere (Remote Desktop Service)
CameraFTP Cloud Surveillance
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Team Anywhere for Windows (Beta)
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
/* 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
Page URL
File URL
Prev
5/10
Next
Download
( 9 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.