wpg.c revision acd2ed254c18c254a0ab5aafa06d1645e5d079d8
13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 43ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% W W PPPP GGGG % 63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% W W P P G % 73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% W W W PPPP G GGG % 83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% WW WW P G G % 93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% W W P GGG % 103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Read WordPerfect Image Format % 133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Software Design % 153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Jaroslav Fojtik % 163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% June 2000 % 173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 197e41fe84a841d7b9d7b36b245b65e9dcb3314943cristy% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % 203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% dedicated to making software imaging solutions freely available. % 213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% You may not use this file except in compliance with the License. You may % 233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% obtain a copy of the License at % 243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% http://www.imagemagick.org/script/license.php % 263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Unless required by applicable law or agreed to in writing, software % 283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% distributed under the License is distributed on an "AS IS" BASIS, % 293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% See the License for the specific language governing permissions and % 313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% limitations under the License. % 323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Include declarations. 403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 414c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/studio.h" 424c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/blob.h" 434c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/blob-private.h" 444c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/color-private.h" 454c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/colormap.h" 464c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/colormap-private.h" 474c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/constitute.h" 484c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception.h" 494c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception-private.h" 504c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/cache.h" 514c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image.h" 524c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image-private.h" 534c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/list.h" 544c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/magic.h" 554c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/magick.h" 564c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/memory_.h" 574c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/resource_.h" 584c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/pixel-accessor.h" 594c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/quantum-private.h" 604c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/shear.h" 614c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/static.h" 624c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/string_.h" 634c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/module.h" 644c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/transform.h" 654c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/utility.h" 663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 673ed852eea50f9d4cd633efb8c2b054b8e33c253cristytypedef struct 683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char Red; 703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char Blue; 713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char Green; 723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } RGB_Record; 733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* Default palette for WPG level 1 */ 753ed852eea50f9d4cd633efb8c2b054b8e33c253cristyconst RGB_Record WPG1_Palette[256]={ 763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0, 0, 0}, { 0, 0,168}, 773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,168, 0}, { 0,168,168}, 783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{168, 0, 0}, {168, 0,168}, 793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{168, 84, 0}, {168,168,168}, 803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 84, 84, 84}, { 84, 84,252}, 813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 84,252, 84}, { 84,252,252}, 823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252, 84, 84}, {252, 84,252}, 833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,252, 84}, {252,252,252}, /*16*/ 843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0, 0, 0}, { 20, 20, 20}, 853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 32, 32, 32}, { 44, 44, 44}, 863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 56, 56, 56}, { 68, 68, 68}, 873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 80, 80, 80}, { 96, 96, 96}, 883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,112,112}, {128,128,128}, 893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{144,144,144}, {160,160,160}, 903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{180,180,180}, {200,200,200}, 913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{224,224,224}, {252,252,252}, /*32*/ 923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0, 0,252}, { 64, 0,252}, 933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124, 0,252}, {188, 0,252}, 943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252, 0,252}, {252, 0,188}, 953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252, 0,124}, {252, 0, 64}, 963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252, 0, 0}, {252, 64, 0}, 973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,124, 0}, {252,188, 0}, 983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,252, 0}, {188,252, 0}, 993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124,252, 0}, { 64,252, 0}, /*48*/ 1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,252, 0}, { 0,252, 64}, 1013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,252,124}, { 0,252,188}, 1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,252,252}, { 0,188,252}, 1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,124,252}, { 0, 64,252}, 1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124,124,252}, {156,124,252}, 1053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{188,124,252}, {220,124,252}, 1063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,124,252}, {252,124,220}, 1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,124,188}, {252,124,156}, /*64*/ 1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,124,124}, {252,156,124}, 1093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,188,124}, {252,220,124}, 1103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,252,124}, {220,252,124}, 1113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{188,252,124}, {156,252,124}, 1123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124,252,124}, {124,252,156}, 1133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124,252,188}, {124,252,220}, 1143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124,252,252}, {124,220,252}, 1153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124,188,252}, {124,156,252}, /*80*/ 1163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{180,180,252}, {196,180,252}, 1173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{216,180,252}, {232,180,252}, 1183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,180,252}, {252,180,232}, 1193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,180,216}, {252,180,196}, 1203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,180,180}, {252,196,180}, 1213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,216,180}, {252,232,180}, 1223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,252,180}, {232,252,180}, 1233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{216,252,180}, {196,252,180}, /*96*/ 1243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{180,220,180}, {180,252,196}, 1253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{180,252,216}, {180,252,232}, 1263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{180,252,252}, {180,232,252}, 1273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{180,216,252}, {180,196,252}, 1283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,112}, {28,0,112}, 1293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{56,0,112}, {84,0,112}, 1303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,0,112}, {112,0,84}, 1313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,0,56}, {112,0,28}, /*112*/ 1323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,0,0}, {112,28,0}, 1333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,56,0}, {112,84,0}, 1343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,112,0}, {84,112,0}, 1353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{56,112,0}, {28,112,0}, 1363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,112,0}, {0,112,28}, 1373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,112,56}, {0,112,84}, 1383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,112,112}, {0,84,112}, 1393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,56,112}, {0,28,112}, /*128*/ 1403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{56,56,112}, {68,56,112}, 1413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{84,56,112}, {96,56,112}, 1423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,56,112}, {112,56,96}, 1433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,56,84}, {112,56,68}, 1443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,56,56}, {112,68,56}, 1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,84,56}, {112,96,56}, 1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,112,56}, {96,112,56}, 1473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{84,112,56}, {68,112,56}, /*144*/ 1483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{56,112,56}, {56,112,69}, 1493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{56,112,84}, {56,112,96}, 1503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{56,112,112}, {56,96,112}, 1513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{56,84,112}, {56,68,112}, 1523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{80,80,112}, {88,80,112}, 1533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{96,80,112}, {104,80,112}, 1543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,80,112}, {112,80,104}, 1553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,80,96}, {112,80,88}, /*160*/ 1563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,80,80}, {112,88,80}, 1573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,96,80}, {112,104,80}, 1583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,112,80}, {104,112,80}, 1593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{96,112,80}, {88,112,80}, 1603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{80,112,80}, {80,112,88}, 1613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{80,112,96}, {80,112,104}, 1623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{80,112,112}, {80,114,112}, 1633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{80,96,112}, {80,88,112}, /*176*/ 1643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,64}, {16,0,64}, 1653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{32,0,64}, {48,0,64}, 1663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,0,64}, {64,0,48}, 1673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,0,32}, {64,0,16}, 1683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,0,0}, {64,16,0}, 1693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,32,0}, {64,48,0}, 1703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,64,0}, {48,64,0}, 1713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{32,64,0}, {16,64,0}, /*192*/ 1723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,64,0}, {0,64,16}, 1733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,64,32}, {0,64,48}, 1743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,64,64}, {0,48,64}, 1753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,32,64}, {0,16,64}, 1763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{32,32,64}, {40,32,64}, 1773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{48,32,64}, {56,32,64}, 1783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,32,64}, {64,32,56}, 1793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,32,48}, {64,32,40}, /*208*/ 1803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,32,32}, {64,40,32}, 1813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,48,32}, {64,56,32}, 1823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,64,32}, {56,64,32}, 1833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{48,64,32}, {40,64,32}, 1843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{32,64,32}, {32,64,40}, 1853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{32,64,48}, {32,64,56}, 1863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{32,64,64}, {32,56,64}, 1873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{32,48,64}, {32,40,64}, /*224*/ 1883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{44,44,64}, {48,44,64}, 1893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{52,44,64}, {60,44,64}, 1903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,44,64}, {64,44,60}, 1913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,44,52}, {64,44,48}, 1923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,44,44}, {64,48,44}, 1933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,52,44}, {64,60,44}, 1943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{64,64,44}, {60,64,44}, 1953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{52,64,44}, {48,64,44}, /*240*/ 1963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{44,64,44}, {44,64,48}, 1973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{44,64,52}, {44,64,60}, 1983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{44,64,64}, {44,60,64}, 1993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{44,55,64}, {44,48,64}, 2003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,0}, {0,0,0}, 2013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,0}, {0,0,0}, 2023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,0}, {0,0,0}, 2033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,0}, {0,0,0} /*256*/ 2043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}; 2053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 2073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% I s W P G % 2123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% IsWPG() returns True if the image format type, identified by the magick 2183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% string, is WPG. 2193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the IsWPG method is: 2213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% unsigned int IsWPG(const unsigned char *magick,const size_t length) 2233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 2253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o status: Method IsWPG returns True if the image format type is WPG. 2273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o magick: compare image format pattern against these bytes. 2293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o length: Specifies the length of the magick string. 2313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2333ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic unsigned int IsWPG(const unsigned char *magick,const size_t length) 2343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 2353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (length < 4) 2363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 2373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (memcmp(magick,"\377WPC",4) == 0) 2383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 2393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 2403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 2413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 243bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic void Rd_WP_DWORD(Image *image,size_t *d) 2443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 2453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 2463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b; 2473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b=ReadBlobByte(image); 2493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *d=b; 2503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (b < 0xFFU) 2513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 2523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b=ReadBlobByte(image); 253bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy *d=(size_t) b; 2543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b=ReadBlobByte(image); 255bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy *d+=(size_t) b*256l; 2563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*d < 0x8000) 2573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 2583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *d=(*d & 0x7FFF) << 16; 2593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b=ReadBlobByte(image); 260bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy *d+=(size_t) b; 2613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b=ReadBlobByte(image); 262bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy *d+=(size_t) b*256l; 2633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 2643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 2653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 266bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic void InsertRow(unsigned char *p,ssize_t y,Image *image, int bpp) 2673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 2683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExceptionInfo 2693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *exception; 2703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 2723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit; 2733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2744c08aed51c5899665ade97263692328eea4af106cristy Quantum 2754c08aed51c5899665ade97263692328eea4af106cristy index; 2763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2774c08aed51c5899665ade97263692328eea4af106cristy register Quantum 2783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 2793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2804c08aed51c5899665ade97263692328eea4af106cristy ssize_t 2814c08aed51c5899665ade97263692328eea4af106cristy x; 2823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy exception=(&image->exception); 2843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (bpp) 2853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: /* Convert bitmap scanline. */ 2873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 289acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 2903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 291bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (x=0; x < ((ssize_t) image->columns-7); x+=8) 2924c08aed51c5899665ade97263692328eea4af106cristy { 2934c08aed51c5899665ade97263692328eea4af106cristy for (bit=0; bit < 8; bit++) 2943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2954c08aed51c5899665ade97263692328eea4af106cristy index=((*p) & (0x80 >> bit) ? 0x01 : 0x00); 2964c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 2974c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 298ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 2993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3004c08aed51c5899665ade97263692328eea4af106cristy p++; 3014c08aed51c5899665ade97263692328eea4af106cristy } 3023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 8) != 0) 3033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 304bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (bit=0; bit < (ssize_t) (image->columns % 8); bit++) 3054c08aed51c5899665ade97263692328eea4af106cristy { 3064c08aed51c5899665ade97263692328eea4af106cristy index=((*p) & (0x80 >> bit) ? 0x01 : 0x00); 3074c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3084c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 309ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3104c08aed51c5899665ade97263692328eea4af106cristy } 3113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 3123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!SyncAuthenticPixels(image,exception)) 3143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: /* Convert PseudoColor scanline. */ 3183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 320acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 3213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 322bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (x=0; x < ((ssize_t) image->columns-1); x+=2) 3233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 6) & 0x3); 3254c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3264c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 327ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 4) & 0x3); 3294c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3304c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 331ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 2) & 0x3); 3334c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3344c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 335ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p) & 0x3); 3374c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3384c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 3393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 340ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 4) != 0) 3433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 6) & 0x3); 3454c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3464c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 347ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 4) >= 1) 3493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 4) & 0x3); 3524c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3534c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 354ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 4) >= 2) 3563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 2) & 0x3); 3594c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3604c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 361ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 3653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (SyncAuthenticPixels(image,exception) == MagickFalse) 3673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: /* Convert PseudoColor scanline. */ 3723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 374acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 3753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 376bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (x=0; x < ((ssize_t) image->columns-1); x+=2) 3773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f); 3794c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3804c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 381ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p) & 0x0f); 3834c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3844c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 3853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 386ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 2) != 0) 3893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f); 3914c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 3924c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 3933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 394ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 3953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (SyncAuthenticPixels(image,exception) == MagickFalse) 3973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: /* Convert PseudoColor scanline. */ 4013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 403acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) break; 4043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 405bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (x=0; x < (ssize_t) image->columns; x++) 4063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,*p); 4084c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(image,index,q); 4094c08aed51c5899665ade97263692328eea4af106cristy SetPixelPacket(image,image->colormap+(ssize_t) index,q); 4103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 411ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 4123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (SyncAuthenticPixels(image,exception) == MagickFalse) 4143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 24: /* Convert DirectColor scanline. */ 4193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 420acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 4213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 422bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (x=0; x < (ssize_t) image->columns; x++) 4233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4244c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(image,ScaleCharToQuantum(*p++),q); 4254c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 4264c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 427ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(image); 4283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!SyncAuthenticPixels(image,exception)) 4303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 4343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* Helper for WPG1 raster reader. */ 4373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define InsertByte(b) \ 4383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \ 4393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff[x]=b; \ 4403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x++; \ 441bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy if((ssize_t) x>=ldblk) \ 4423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { \ 443bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy InsertRow(BImgBuff,(ssize_t) y,image,bpp); \ 4443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; \ 4453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; \ 4463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } \ 4473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 4483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* WPG1 raster reader. */ 4493ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int UnpackWPGRaster(Image *image,int bpp) 4503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 4513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 4523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 4533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y, 4543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 4553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 4573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf, 4583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *BImgBuff, 4593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount; 4603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 461bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy ssize_t 4623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk; 4633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 4653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 4663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 467bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy ldblk=(ssize_t) ((bpp*image->columns+7)/8); 4683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk, 4693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*BImgBuff)); 4703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BImgBuff==NULL) return(-2); 4713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 472bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy while(y<(ssize_t) image->rows) 4733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 4753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=bbuf & 0x7F; 4773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(bbuf & 0x80) 4783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(RunCount) /* repeat next byte runcount * */ 4803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 4823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i<(int) RunCount;i++) InsertByte(bbuf); 4833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else { /* read next byte as RunCount; repeat 0xFF runcount* */ 4853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=ReadBlobByte(image); 4863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i<(int) RunCount;i++) InsertByte(0xFF); 4873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else { 4903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(RunCount) /* next runcount byte are readed directly */ 4913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i < (int) RunCount;i++) 4933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 4953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertByte(bbuf); 4963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else { /* repeat previous line runcount* */ 4993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=ReadBlobByte(image); 5003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(x) { /* attempt to duplicate row from x position: */ 5013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* I do not know what to do here */ 5023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 5033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-3); 5043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i < (int) RunCount;i++) 5063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 5083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; /* Here I need to duplicate previous row RUNCOUNT* */ 5093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(y<2) continue; 510bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy if(y>(ssize_t) image->rows) 5113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 5133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-4); 5143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertRow(BImgBuff,y-1,image,bpp); 5163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 5213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 5223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 5233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* Helper for WPG2 reader. */ 5263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define InsertByte6(b) \ 5273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \ 5283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(XorMe)\ 5293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff[x] = (unsigned char)~b;\ 5303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else\ 5313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff[x] = b;\ 5323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x++; \ 533bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy if((ssize_t) x >= ldblk) \ 5343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { \ 535bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy InsertRow(BImgBuff,(ssize_t) y,image,bpp); \ 5363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; \ 5373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; \ 5383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } \ 5393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 5403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* WPG2 raster reader. */ 5413ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int UnpackWPG2Raster(Image *image,int bpp) 5423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 5436a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy size_t 5446a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy x, 5456a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy y; 5466a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy 5476a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy ssize_t 5486a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy ldblk; 5496a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy 5506a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy int XorMe = 0; 5516a1c5a9375dfad129bc7d6ae8f3eadea60cebe46cristy 5523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 5533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SampleSize=1; 5543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 5563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf, 5573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *BImgBuff, 5583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount, 5593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SampleBuffer[8]; 5603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 5623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 5633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 5653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 566bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy ldblk=(ssize_t) ((bpp*image->columns+7)/8); 5673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk, 5683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*BImgBuff)); 5693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BImgBuff==NULL) 5703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-2); 5713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while( y< image->rows) 5733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 5753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(bbuf) 5773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x7D: 5793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SampleSize=ReadBlobByte(image); /* DSZ */ 5803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(SampleSize>8) 5813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-2); 5823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(SampleSize<1) 5833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-2); 5843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 5853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x7E: 5861e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(stderr, 5871e604812fad85bb96f757a2393015ae3d061c39acristy "\nUnsupported WPG token XOR, please report!"); 5881e604812fad85bb96f757a2393015ae3d061c39acristy XorMe=!XorMe; 5893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 5903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x7F: 5913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=ReadBlobByte(image); /* BLK */ 5923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0; i < SampleSize*(RunCount+1); i++) 5933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertByte6(0); 5953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 5973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0xFD: 5981e604812fad85bb96f757a2393015ae3d061c39acristy RunCount=ReadBlobByte(image); /* EXT */ 5991e604812fad85bb96f757a2393015ae3d061c39acristy for(i=0; i<= RunCount;i++) 6003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(bbuf=0; bbuf < SampleSize; bbuf++) 6013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertByte6(SampleBuffer[bbuf]); 6023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0xFE: 6043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=ReadBlobByte(image); /* RST */ 6053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(x!=0) 6063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 607b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(stderr, 6081e604812fad85bb96f757a2393015ae3d061c39acristy "\nUnsupported WPG2 unaligned token RST x=%.20g, please report!\n" 6091e604812fad85bb96f757a2393015ae3d061c39acristy ,(double) x); 6103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-3); 6113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* duplicate the previous row RunCount x */ 6143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i<=RunCount;i++) 6153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 616bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy InsertRow(BImgBuff,(ssize_t) (image->rows >= y ? y : image->rows-1), 6173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image,bpp); 6183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 6193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0xFF: 6233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=ReadBlobByte(image); /* WHT */ 6243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0; i < SampleSize*(RunCount+1); i++) 6253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertByte6(0xFF); 6273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 6303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=bbuf & 0x7F; 6313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(bbuf & 0x80) /* REP */ 6333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0; i < SampleSize; i++) 6353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SampleBuffer[i]=ReadBlobByte(image); 6363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i<=RunCount;i++) 6373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(bbuf=0;bbuf<SampleSize;bbuf++) 6383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertByte6(SampleBuffer[bbuf]); 6393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else { /* NRP */ 6413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0; i< SampleSize*(RunCount+1);i++) 6423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 6443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertByte6(bbuf); 6453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 6503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 6513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 6523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6543ed852eea50f9d4cd633efb8c2b054b8e33c253cristytypedef float tCTM[3][3]; 6553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6563ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic unsigned LoadWPG2Flags(Image *image,char Precision,float *Angle,tCTM *CTM) 6573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 6583ed852eea50f9d4cd633efb8c2b054b8e33c253cristyconst unsigned char TPR=1,TRN=2,SKW=4,SCL=8,ROT=0x10,OID=0x20,LCK=0x80; 659bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristyssize_t x; 6603ed852eea50f9d4cd633efb8c2b054b8e33c253cristyunsigned DenX; 6613ed852eea50f9d4cd633efb8c2b054b8e33c253cristyunsigned Flags; 6623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) memset(*CTM,0,sizeof(*CTM)); /*CTM.erase();CTM.resize(3,3);*/ 6643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[0][0]=1; 6653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[1][1]=1; 6663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[2][2]=1; 6673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Flags=ReadBlobLSBShort(image); 6693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & LCK) x=ReadBlobLSBLong(image); /*Edit lock*/ 6703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & OID) 6713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Precision==0) 6733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy {x=ReadBlobLSBShort(image);} /*ObjectID*/ 6743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 6753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy {x=ReadBlobLSBLong(image);} /*ObjectID (Double precision)*/ 6763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & ROT) 6783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Rot Angle*/ 6803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Angle) *Angle=x/65536.0; 6813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & (ROT|SCL)) 6833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Sx*cos()*/ 6853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[0][0] = (float)x/0x10000; 6863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Sy*cos()*/ 6873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[1][1] = (float)x/0x10000; 6883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & (ROT|SKW)) 6903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Kx*sin()*/ 6923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[1][0] = (float)x/0x10000; 6933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Ky*sin()*/ 6943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[0][1] = (float)x/0x10000; 6953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & TRN) 6973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); DenX=ReadBlobLSBShort(image); /*Tx*/ 6993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(x>=0) (*CTM)[0][2] = (float)x+(float)DenX/0x10000; 7003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else (*CTM)[0][2] = (float)x-(float)DenX/0x10000; 7013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); DenX=ReadBlobLSBShort(image); /*Ty*/ 7023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[1][2]=(float)x + ((x>=0)?1:-1)*(float)DenX/0x10000; 7033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(x>=0) (*CTM)[1][2] = (float)x+(float)DenX/0x10000; 7043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else (*CTM)[1][2] = (float)x-(float)DenX/0x10000; 7053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & TPR) 7073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBShort(image); DenX=ReadBlobLSBShort(image); /*Px*/ 7093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[2][0] = x + (float)DenX/0x10000;; 7103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBShort(image); DenX=ReadBlobLSBShort(image); /*Py*/ 7113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[2][1] = x + (float)DenX/0x10000; 7123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(Flags); 7143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 7153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7173ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Image *ExtractPostscript(Image *image,const ImageInfo *image_info, 718bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy MagickOffsetType PS_Offset,ssize_t PS_Size,ExceptionInfo *exception) 7193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 7203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 7213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy postscript_file[MaxTextExtent]; 7223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const MagicInfo 7243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *magic_info; 7253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FILE 7273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ps_file; 7283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ImageInfo 7303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *clone_info; 7313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 7333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image2; 7343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 7363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick[2*MaxTextExtent]; 7373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((clone_info=CloneImageInfo(image_info)) == NULL) 7403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 7413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy clone_info->blob=(void *) NULL; 7423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy clone_info->length=0; 7433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Obtain temporary file */ 7453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AcquireUniqueFilename(postscript_file); 7463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ps_file=OpenMagickStream(postscript_file,"wb"); 7473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ps_file == (FILE *) NULL) 7483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto FINISH; 7493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Copy postscript to temporary file */ 7513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SeekBlob(image,PS_Offset,SEEK_SET); 7523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ReadBlob(image, 2*MaxTextExtent, magick); 7533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SeekBlob(image,PS_Offset,SEEK_SET); 7553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while(PS_Size-- > 0) 7563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) fputc(ReadBlobByte(image),ps_file); 7583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) fclose(ps_file); 7603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Detect file format - Check magic.mgk configuration file. */ 7623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magic_info=GetMagicInfo(magick,2*MaxTextExtent,exception); 7633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(magic_info == (const MagicInfo *) NULL) goto FINISH_UNL; 7643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* printf("Detected:%s \n",magic_info->name); */ 7653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(exception->severity != UndefinedException) goto FINISH_UNL; 7663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(magic_info->name == (char *) NULL) goto FINISH_UNL; 7673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(clone_info->magick,magic_info->name,MaxTextExtent); 7693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Read nested image */ 77153a8bc9b0c80f3027e032dcd8e77d8987c53bd6fcristy /*FormatString(clone_info->filename,"%s:%s",magic_info->name,postscript_file);*/ 772b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy FormatLocaleString(clone_info->filename,MaxTextExtent,"%s",postscript_file); 7733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image2=ReadImage(clone_info,exception); 7743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!image2) 7763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto FINISH_UNL; 7773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 7793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Replace current image with new image while copying base image 7803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy attributes. 7813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(image2->filename,image->filename,MaxTextExtent); 7833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(image2->magick_filename,image->magick_filename,MaxTextExtent); 7843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(image2->magick,image->magick,MaxTextExtent); 7853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image2->depth=image->depth; 7863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DestroyBlob(image2); 7873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image2->blob=ReferenceBlob(image->blob); 7883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->rows == 0) || (image->columns == 0)) 7903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DeleteImageFromList(&image); 7913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,image2); 7933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FINISH_UNL: 7953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RelinquishUniqueFileResource(postscript_file); 7963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FINISH: 7973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DestroyImageInfo(clone_info); 7983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 7993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 8003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 8023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% R e a d W P G I m a g e % 8073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Method ReadWPGImage reads an WPG X image file and returns it. It 8133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% allocates the memory necessary for the new Image structure and returns a 8143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% pointer to the new image. 8153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the ReadWPGImage method is: 8173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Image *ReadWPGImage(const ImageInfo *image_info,ExceptionInfo *exception) 8193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 8213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: Method ReadWPGImage returns a pointer to the image after 8233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% reading. A null image is returned if there is a memory shortage or if 8243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the image cannot be read. 8253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image_info: Specifies a pointer to a ImageInfo structure. 8273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o exception: return any errors or warnings in this structure. 8293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 8313ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Image *ReadWPGImage(const ImageInfo *image_info, 8323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExceptionInfo *exception) 8333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 8343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 836bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t FileId; 8373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickOffsetType DataOffset; 8383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int ProductType; 8393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int FileType; 8403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char MajorVersion; 8413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char MinorVersion; 8423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int EncryptKey; 8433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Reserved; 8443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGHeader; 8453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char RecType; 849bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t RecordLength; 8503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGRecord; 8513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char Class; 8553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char RecType; 856bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t Extension; 857bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t RecordLength; 8583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPG2Record; 8593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned HorizontalUnits; 8633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned VerticalUnits; 8643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char PosSizePrecision; 8653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPG2Start; 8663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Width; 8703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Heigth; 8713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Depth; 8723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int HorzRes; 8733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int VertRes; 8743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGBitmapType1; 8753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Width; 8793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Heigth; 8803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char Depth; 8813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char Compression; 8823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPG2BitmapType1; 8833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int RotAngle; 8873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int LowLeftX; 8883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int LowLeftY; 8893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int UpRightX; 8903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int UpRightY; 8913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Width; 8923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Heigth; 8933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Depth; 8943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int HorzRes; 8953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int VertRes; 8963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGBitmapType2; 8973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int StartIndex; 9013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int NumOfEntries; 9023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGColorMapRec; 9033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct { 905bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t PS_unknown1; 9063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int PS_unknown2; 9073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int PS_unknown3; 9083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGPSl1Record; 9093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 9113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image, 9123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *rotated_image; 9133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 9153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 9163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPGHeader 9183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header; 9193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPGRecord 9213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rec; 9223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG2Record 9243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rec2; 9253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG2Start StartWPG; 9273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPGBitmapType1 9293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader1; 9303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG2BitmapType1 9323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Bitmap2Header1; 9333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPGBitmapType2 9353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2; 9363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPGColorMapRec 9383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG_Palette; 9393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 9413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 9423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp, 9433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG2Flags; 9443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 945bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy ssize_t 9463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk; 9473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 948eaedf06777741da32408da72c1e512975c600c48cristy size_t 949eaedf06777741da32408da72c1e512975c600c48cristy one; 950eaedf06777741da32408da72c1e512975c600c48cristy 9513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 9523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *BImgBuff; 9533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy tCTM CTM; /*current transform matrix*/ 9553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Open image file. 9583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info != (const ImageInfo *) NULL); 9603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info->signature == MagickSignature); 9613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(exception != (ExceptionInfo *) NULL); 9623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(exception->signature == MagickSignature); 963eaedf06777741da32408da72c1e512975c600c48cristy one=1; 9643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=AcquireImage(image_info); 9653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->depth=8; 9663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); 9673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == MagickFalse) 9683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=DestroyImageList(image); 9703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 9713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Read WPG image. 9743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.FileId=ReadBlobLSBLong(image); 9763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.DataOffset=(MagickOffsetType) ReadBlobLSBLong(image); 9773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.ProductType=ReadBlobLSBShort(image); 9783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.FileType=ReadBlobLSBShort(image); 9793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.MajorVersion=ReadBlobByte(image); 9803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.MinorVersion=ReadBlobByte(image); 9813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.EncryptKey=ReadBlobLSBShort(image); 9823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.Reserved=ReadBlobLSBShort(image); 9833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (Header.FileId!=0x435057FF || (Header.ProductType>>8)!=0x16) 9853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CorruptImageError,"ImproperImageHeader"); 9863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (Header.EncryptKey!=0) 9873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CoderError,"EncryptedWPGImageFileNotSupported"); 9883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns = 1; 9903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->rows = 1; 9913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors = 0; 9923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=0; 9933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.RotAngle=0; 9943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Header.FileType) 9963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: /* WPG level 1 */ 9983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while(!EOFBlob(image)) /* object parser loop */ 9993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SeekBlob(image,Header.DataOffset,SEEK_SET); 10013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(EOFBlob(image)) 10023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 10033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rec.RecType=(i=ReadBlobByte(image)); 10053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(i==EOF) 10063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 10073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rd_WP_DWORD(image,&Rec.RecordLength); 10083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(EOFBlob(image)) 10093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 10103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.DataOffset=TellBlob(image)+Rec.RecordLength; 10123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Rec.RecType) 10143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x0B: /* bitmap type 1 */ 10163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader1.Width=ReadBlobLSBShort(image); 10173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader1.Heigth=ReadBlobLSBShort(image); 10183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader1.Depth=ReadBlobLSBShort(image); 10193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader1.HorzRes=ReadBlobLSBShort(image); 10203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader1.VertRes=ReadBlobLSBShort(image); 10213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BitmapHeader1.HorzRes && BitmapHeader1.VertRes) 10233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->units=PixelsPerCentimeterResolution; 10253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->x_resolution=BitmapHeader1.HorzRes/470.0; 10263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->y_resolution=BitmapHeader1.VertRes/470.0; 10273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns=BitmapHeader1.Width; 10293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->rows=BitmapHeader1.Heigth; 10303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=BitmapHeader1.Depth; 10313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto UnpackRaster; 10333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x0E: /*Color palette */ 10353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG_Palette.StartIndex=ReadBlobLSBShort(image); 10363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); 10373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors=WPG_Palette.NumOfEntries; 10393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!AcquireImageColormap(image,image->colors)) 10403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto NoMemory; 10413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=WPG_Palette.StartIndex; 10423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i < (int)WPG_Palette.NumOfEntries; i++) 10433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].red=ScaleCharToQuantum((unsigned char) 10453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 10463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].green=ScaleCharToQuantum((unsigned char) 10473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 10483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].blue=ScaleCharToQuantum((unsigned char) 10493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 10503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 10523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x11: /* Start PS l1 */ 10543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Rec.RecordLength > 8) 10553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=ExtractPostscript(image,image_info, 10563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy TellBlob(image)+8, /* skip PS header in the wpg */ 1057bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (ssize_t) Rec.RecordLength-8,exception); 10583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 10593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x14: /* bitmap type 2 */ 10613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.RotAngle=ReadBlobLSBShort(image); 10623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.LowLeftX=ReadBlobLSBShort(image); 10633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.LowLeftY=ReadBlobLSBShort(image); 10643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.UpRightX=ReadBlobLSBShort(image); 10653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.UpRightY=ReadBlobLSBShort(image); 10663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.Width=ReadBlobLSBShort(image); 10673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.Heigth=ReadBlobLSBShort(image); 10683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.Depth=ReadBlobLSBShort(image); 10693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.HorzRes=ReadBlobLSBShort(image); 10703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BitmapHeader2.VertRes=ReadBlobLSBShort(image); 10713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->units=PixelsPerCentimeterResolution; 10733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->page.width=(unsigned int) 10743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightX)/470.0); 10753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->page.height=(unsigned int) 10763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightY)/470.0); 10773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->page.x=(int) (BitmapHeader2.LowLeftX/470.0); 10783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->page.y=(int) (BitmapHeader2.LowLeftX/470.0); 10793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BitmapHeader2.HorzRes && BitmapHeader2.VertRes) 10803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->x_resolution=BitmapHeader2.HorzRes/470.0; 10823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->y_resolution=BitmapHeader2.VertRes/470.0; 10833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns=BitmapHeader2.Width; 10853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->rows=BitmapHeader2.Heigth; 10863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=BitmapHeader2.Depth; 10873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy UnpackRaster: 10893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->colors == 0) && (bpp != 24)) 10903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1091eaedf06777741da32408da72c1e512975c600c48cristy image->colors=one << bpp; 10923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!AcquireImageColormap(image,image->colors)) 10933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy NoMemory: 10953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(ResourceLimitError, 10963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed"); 10973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* printf("Load default colormap \n"); */ 10993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; (i < (int) image->colors) && (i < 256); i++) 11003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].red=ScaleCharToQuantum(WPG1_Palette[i].Red); 11023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].green=ScaleCharToQuantum(WPG1_Palette[i].Green); 11033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].blue=ScaleCharToQuantum(WPG1_Palette[i].Blue); 11043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 11073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bpp < 24) 1109eaedf06777741da32408da72c1e512975c600c48cristy if ( (image->colors < (one << bpp)) && (bpp != 24) ) 11103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap=(PixelPacket *) ResizeQuantumMemory( 1111eaedf06777741da32408da72c1e512975c600c48cristy image->colormap,(size_t) (one << bpp), 11123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*image->colormap)); 11133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bpp == 1) 11163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(image->colormap[0].red==0 && 11183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[0].green==0 && 11193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[0].blue==0 && 11203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[1].red==0 && 11213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[1].green==0 && 11223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[1].blue==0) 11233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { /* fix crippled monochrome palette */ 11243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[1].red = 11253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[1].green = 11263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[1].blue = QuantumRange; 11273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(UnpackWPGRaster(image,bpp) < 0) 11313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* The raster cannot be unpacked */ 11323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DecompressionFailed: 11343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CoderError,"UnableToDecompressImage"); 11353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Rec.RecType==0x14 && BitmapHeader2.RotAngle!=0 && !image_info->ping) 11383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* flop command */ 11403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BitmapHeader2.RotAngle & 0x8000) 11413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image = FlopImage(image, exception); 11433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image->blob = image->blob; 11443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(rotated_image,image); 11453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 11463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,rotated_image); 11473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* flip command */ 11493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BitmapHeader2.RotAngle & 0x2000) 11503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image = FlipImage(image, exception); 11523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image->blob = image->blob; 11533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(rotated_image,image); 11543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 11553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,rotated_image); 11563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* rotate command */ 11593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BitmapHeader2.RotAngle & 0x0FFF) 11603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image = RotateImage(image, (BitmapHeader2.RotAngle & 0x0FFF), exception); 11623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image->blob = image->blob; 11633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(rotated_image,image); 11643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 11653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,rotated_image); 11663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Allocate next image structure. */ 11703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AcquireNextImage(image_info,image); 11713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->depth=8; 11723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->next == (Image *) NULL) 11733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto Finish; 11743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=SyncNextImageInList(image); 11753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns=image->rows=0; 11763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors=0; 11773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 11783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x1B: /* Postscript l2 */ 11803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Rec.RecordLength>0x3C) 11813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=ExtractPostscript(image,image_info, 11823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy TellBlob(image)+0x3C, /* skip PS l2 header in the wpg */ 1183bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (ssize_t) Rec.RecordLength-0x3C,exception); 11843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 11853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 11883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: /* WPG level 2 */ 11903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) memset(CTM,0,sizeof(CTM)); 11913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StartWPG.PosSizePrecision = 0; 11923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while(!EOFBlob(image)) /* object parser loop */ 11933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SeekBlob(image,Header.DataOffset,SEEK_SET); 11953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(EOFBlob(image)) 11963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 11973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rec2.Class=(i=ReadBlobByte(image)); 11993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(i==EOF) 12003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rec2.RecType=(i=ReadBlobByte(image)); 12023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(i==EOF) 12033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rd_WP_DWORD(image,&Rec2.Extension); 12053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rd_WP_DWORD(image,&Rec2.RecordLength); 12063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(EOFBlob(image)) 12073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.DataOffset=TellBlob(image)+Rec2.RecordLength; 12103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Rec2.RecType) 12123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 12143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StartWPG.HorizontalUnits=ReadBlobLSBShort(image); 12153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StartWPG.VerticalUnits=ReadBlobLSBShort(image); 12163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StartWPG.PosSizePrecision=ReadBlobByte(image); 12173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x0C: /* Color palette */ 12193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG_Palette.StartIndex=ReadBlobLSBShort(image); 12203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); 12213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors=WPG_Palette.NumOfEntries; 12233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (AcquireImageColormap(image,image->colors) == MagickFalse) 12243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(ResourceLimitError, 12253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed"); 12263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=WPG_Palette.StartIndex; 12273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i < (int)WPG_Palette.NumOfEntries; i++) 12283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].red=ScaleCharToQuantum((char) 12303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 12313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].green=ScaleCharToQuantum((char) 12323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 12333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].blue=ScaleCharToQuantum((char) 12343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 12353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ReadBlobByte(image); /*Opacity??*/ 12363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x0E: 12393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Bitmap2Header1.Width=ReadBlobLSBShort(image); 12403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Bitmap2Header1.Heigth=ReadBlobLSBShort(image); 12413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Bitmap2Header1.Depth=ReadBlobByte(image); 12423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Bitmap2Header1.Compression=ReadBlobByte(image); 12433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Bitmap2Header1.Compression > 1) 12453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; /*Unknown compression method */ 12463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Bitmap2Header1.Depth) 12473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 12493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=1; 12503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 12523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=2; 12533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 12553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=4; 12563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 12583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=8; 12593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 12613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=24; 12623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 12643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; /*Ignore raster with unknown depth*/ 12653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns=Bitmap2Header1.Width; 12673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->rows=Bitmap2Header1.Heigth; 12683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->colors == 0) && (bpp != 24)) 12703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12710b29b25525c4612c77b1b3c8abcc40685d0aa33fcristy size_t 12720b29b25525c4612c77b1b3c8abcc40685d0aa33fcristy one; 12730b29b25525c4612c77b1b3c8abcc40685d0aa33fcristy 12740b29b25525c4612c77b1b3c8abcc40685d0aa33fcristy one=1; 12750b29b25525c4612c77b1b3c8abcc40685d0aa33fcristy image->colors=one << bpp; 12763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!AcquireImageColormap(image,image->colors)) 12773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto NoMemory; 12783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(bpp < 24) 1282eaedf06777741da32408da72c1e512975c600c48cristy if( image->colors<(one << bpp) && bpp!=24 ) 12833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap=(PixelPacket *) ResizeQuantumMemory( 1284eaedf06777741da32408da72c1e512975c600c48cristy image->colormap,(size_t) (one << bpp), 12853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*image->colormap)); 12863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Bitmap2Header1.Compression) 12903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: /*Uncompressed raster*/ 12923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1293bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy ldblk=(ssize_t) ((bpp*image->columns+7)/8); 12943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) 12953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk,sizeof(*BImgBuff)); 12963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (BImgBuff == (unsigned char *) NULL) 12973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto NoMemory; 12983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1299bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for(i=0; i< (ssize_t) image->rows; i++) 13003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ReadBlob(image,ldblk,BImgBuff); 13023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertRow(BImgBuff,i,image,bpp); 13033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BImgBuff) 13063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);; 13073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: /*RLE for WPG2 */ 13103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if( UnpackWPG2Raster(image,bpp) < 0) 13123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto DecompressionFailed; 13133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(CTM[0][0]<0 && !image_info->ping) 13183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { /*?? RotAngle=360-RotAngle;*/ 13193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image = FlopImage(image, exception); 13203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image->blob = image->blob; 13213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(rotated_image,image); 13223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 13233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,rotated_image); 13243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Try to change CTM according to Flip - I am not sure, must be checked. 13253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,0)=-1; Tx(1,0)=0; Tx(2,0)=0; 13263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,1)= 0; Tx(1,1)=1; Tx(2,1)=0; 13273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,2)=(WPG._2Rect.X_ur+WPG._2Rect.X_ll); 13283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(1,2)=0; Tx(2,2)=1; */ 13293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(CTM[1][1]<0 && !image_info->ping) 13313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { /*?? RotAngle=360-RotAngle;*/ 13323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image = FlipImage(image, exception); 13333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotated_image->blob = image->blob; 13343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(rotated_image,image); 13353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 13363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,rotated_image); 13373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Try to change CTM according to Flip - I am not sure, must be checked. 13383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy float_matrix Tx(3,3); 13393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,0)= 1; Tx(1,0)= 0; Tx(2,0)=0; 13403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,1)= 0; Tx(1,1)=-1; Tx(2,1)=0; 13413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,2)= 0; Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll); 13423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(2,2)=1; */ 13433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Allocate next image structure. */ 13473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AcquireNextImage(image_info,image); 13483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->depth=8; 13493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->next == (Image *) NULL) 13503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto Finish; 13513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=SyncNextImageInList(image); 13523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns=image->rows=1; 13533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors=0; 13543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x12: /* Postscript WPG2*/ 13573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=ReadBlobLSBShort(image); 13583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Rec2.RecordLength > (unsigned int) i) 13593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=ExtractPostscript(image,image_info, 13603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy TellBlob(image)+i, /*skip PS header in the wpg2*/ 1361bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (ssize_t) (Rec2.RecordLength-i-2),exception); 13623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x1B: /*bitmap rectangle*/ 13653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG2Flags = LoadWPG2Flags(image,StartWPG.PosSizePrecision,NULL,&CTM); 1366da16f16767eb31921af855f17bda465fffc4e000cristy (void) WPG2Flags; 13673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 13743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CoderError,"DataEncodingSchemeIsNotSupported"); 13763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Finish: 13803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloseBlob(image); 13813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 13843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 13853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1386bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy ssize_t 13873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scene=0; 13883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rewind list, removing any empty images while rewinding. 13913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 13923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=image; 13933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=NULL; 13943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (p != (Image *) NULL) 13953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image *tmp=p; 13973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((p->rows == 0) || (p->columns == 0)) { 13983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=p->previous; 13993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DeleteImageFromList(&tmp); 14003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } else { 14013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=p; 14023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=p->previous; 14033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 14063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Fix scene numbers. 14073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 14083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (p=image; p != (Image *) NULL; p=p->next) 1409bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy p->scene=(size_t) scene++; 14103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image == (Image *) NULL) 14123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CorruptImageError, 14133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "ImageFileDoesNotContainAnyImageData"); 14143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 14153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 14163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 14183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% R e g i s t e r W P G I m a g e % 14233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Method RegisterWPGImage adds attributes for the WPG image format to 14293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the list of supported formats. The attributes include the image format 14303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% tag, a method to read and/or write the format, whether the format 14313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% supports the saving of more than one frame to the same file or blob, 14323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% whether the format supports native in-memory I/O, and a brief 14333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% description of the format. 14343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the RegisterWPGImage method is: 14363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 1437bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy% size_t RegisterWPGImage(void) 14383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1440bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristyModuleExport size_t RegisterWPGImage(void) 14413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 14423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickInfo 14433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *entry; 14443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy entry=SetMagickInfo("WPG"); 14463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy entry->decoder=(DecodeImageHandler *) ReadWPGImage; 14473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy entry->magick=(IsImageFormatHandler *) IsWPG; 14483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy entry->description=AcquireString("Word Perfect Graphics"); 14493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy entry->module=ConstantString("WPG"); 14503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy entry->seekable_stream=MagickTrue; 14513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RegisterMagickInfo(entry); 14523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickImageCoderSignature); 14533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 14543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 14563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% U n r e g i s t e r W P G I m a g e % 14613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Method UnregisterWPGImage removes format registrations made by the 14673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% WPG module from the list of supported formats. 14683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the UnregisterWPGImage method is: 14703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% UnregisterWPGImage(void) 14723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 14743ed852eea50f9d4cd633efb8c2b054b8e33c253cristyModuleExport void UnregisterWPGImage(void) 14753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 14763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) UnregisterMagickInfo("WPG"); 14773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 1478