wpg.c revision fc43974d34318c834fbf78570ca1a3764ed8c7d7
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 % 16de984cdc3631106b1cbbb8d3972b76a0fc27e8e8cristy% June 2000 % 173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization % 207ce65e7125a4e1df1a274ce373c537a9df9c16cdCristy% 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*/ 413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "MagickCore/studio.h" 423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "MagickCore/blob.h" 433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "MagickCore/blob-private.h" 443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "MagickCore/color-private.h" 454c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/colormap.h" 464c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/colormap-private.h" 475ff4eaf57b3cd47d0371f204f865cbba614674a0cristy#include "MagickCore/constitute.h" 484c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception.h" 494c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception-private.h" 50c9afe1687cd4da5d2382a9ca3ca12f30d8baa96fcristy#include "MagickCore/cache.h" 514c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/distort.h" 524c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image.h" 534c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image-private.h" 5454b92627b2e9657853beee431546d08234276477cristy#include "MagickCore/list.h" 554c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/magic.h" 564c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/magick.h" 574c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/memory_.h" 584c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/resource_.h" 594c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/pixel-accessor.h" 603644bdf56f0081bcae1f4dbc69c2d06713f6203bcristy#include "MagickCore/quantum-private.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" 664c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/utility-private.h" 674c08aed51c5899665ade97263692328eea4af106cristy 684c08aed51c5899665ade97263692328eea4af106cristytypedef struct 694c08aed51c5899665ade97263692328eea4af106cristy { 704c08aed51c5899665ade97263692328eea4af106cristy unsigned char Red; 714c08aed51c5899665ade97263692328eea4af106cristy unsigned char Blue; 724c08aed51c5899665ade97263692328eea4af106cristy unsigned char Green; 734c08aed51c5899665ade97263692328eea4af106cristy } RGB_Record; 744c08aed51c5899665ade97263692328eea4af106cristy 7517f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy/* Default palette for WPG level 1 */ 764c08aed51c5899665ade97263692328eea4af106cristystatic const RGB_Record WPG1_Palette[256]={ 7706f590165f0505d42005264893fe14a9e8a79986dirk{ 0, 0, 0}, { 0, 0,168}, 784c08aed51c5899665ade97263692328eea4af106cristy{ 0,168, 0}, { 0,168,168}, 794c08aed51c5899665ade97263692328eea4af106cristy{168, 0, 0}, {168, 0,168}, 80d1dd6e4fefa0810b9893e6ac9418f79c97c1b39acristy{168, 84, 0}, {168,168,168}, 81bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy{ 84, 84, 84}, { 84, 84,252}, 824c08aed51c5899665ade97263692328eea4af106cristy{ 84,252, 84}, { 84,252,252}, 833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252, 84, 84}, {252, 84,252}, 8407a3cca00593c795eb8e0427f5bc4c2bcad3f0fbcristy{252,252, 84}, {252,252,252}, /*16*/ 853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0, 0, 0}, { 20, 20, 20}, 863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 32, 32, 32}, { 44, 44, 44}, 8703f187ee83f1927717c93c57af06d5e030a194becristy{ 56, 56, 56}, { 68, 68, 68}, 883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 80, 80, 80}, { 96, 96, 96}, 893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,112,112}, {128,128,128}, 903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{144,144,144}, {160,160,160}, 913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{180,180,180}, {200,200,200}, 923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{224,224,224}, {252,252,252}, /*32*/ 933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0, 0,252}, { 64, 0,252}, 943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124, 0,252}, {188, 0,252}, 953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252, 0,252}, {252, 0,188}, 963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252, 0,124}, {252, 0, 64}, 973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252, 0, 0}, {252, 64, 0}, 983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,124, 0}, {252,188, 0}, 993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,252, 0}, {188,252, 0}, 1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124,252, 0}, { 64,252, 0}, /*48*/ 1013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,252, 0}, { 0,252, 64}, 1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,252,124}, { 0,252,188}, 1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,252,252}, { 0,188,252}, 1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 0,124,252}, { 0, 64,252}, 1053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{124,124,252}, {156,124,252}, 1063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{188,124,252}, {220,124,252}, 1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,124,252}, {252,124,220}, 1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{252,124,188}, {252,124,156}, /*64*/ 10917f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy{252,124,124}, {252,156,124}, 11069a0d3b5699c573f650e6b61f98ce4579d6f218cCristy{252,188,124}, {252,220,124}, 111ea866ca14ef4019d49cf678d35b405512b210b85Cristy{252,252,124}, {220,252,124}, 11217f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy{188,252,124}, {156,252,124}, 11369a0d3b5699c573f650e6b61f98ce4579d6f218cCristy{124,252,124}, {124,252,156}, 11487dc5e4e6f9471304ba85f508de30e664b484d3aCristy{124,252,188}, {124,252,220}, 11569a0d3b5699c573f650e6b61f98ce4579d6f218cCristy{124,252,252}, {124,220,252}, 11669a0d3b5699c573f650e6b61f98ce4579d6f218cCristy{124,188,252}, {124,156,252}, /*80*/ 11769a0d3b5699c573f650e6b61f98ce4579d6f218cCristy{180,180,252}, {196,180,252}, 11869a0d3b5699c573f650e6b61f98ce4579d6f218cCristy{216,180,252}, {232,180,252}, 11969a0d3b5699c573f650e6b61f98ce4579d6f218cCristy{252,180,252}, {252,180,232}, 12087dc5e4e6f9471304ba85f508de30e664b484d3aCristy{252,180,216}, {252,180,196}, 12169a0d3b5699c573f650e6b61f98ce4579d6f218cCristy{252,180,180}, {252,196,180}, 12217f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy{252,216,180}, {252,232,180}, 1235eb36084e86f5ab4a877c2b31c19880b0b0b02e3Cristy{252,252,180}, {232,252,180}, 1243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{216,252,180}, {196,252,180}, /*96*/ 125d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{180,220,180}, {180,252,196}, 126d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{180,252,216}, {180,252,232}, 127d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{180,252,252}, {180,232,252}, 128d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{180,216,252}, {180,196,252}, 129d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{0,0,112}, {28,0,112}, 130d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{56,0,112}, {84,0,112}, 1313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,0,112}, {112,0,84}, 1323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,0,56}, {112,0,28}, /*112*/ 1333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,0,0}, {112,28,0}, 1345cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy{112,56,0}, {112,84,0}, 1355cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy{112,112,0}, {84,112,0}, 1365cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy{56,112,0}, {28,112,0}, 1375cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy{0,112,0}, {0,112,28}, 1383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,112,56}, {0,112,84}, 1395cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy{0,112,112}, {0,84,112}, 1405cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy{0,56,112}, {0,28,112}, /*128*/ 1415cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy{56,56,112}, {68,56,112}, 1423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{84,56,112}, {96,56,112}, 1433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,56,112}, {112,56,96}, 1443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,56,84}, {112,56,68}, 1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,56,56}, {112,68,56}, 1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,84,56}, {112,96,56}, 1473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{112,112,56}, {96,112,56}, 148d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{84,112,56}, {68,112,56}, /*144*/ 149d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{56,112,56}, {56,112,69}, 150d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{56,112,84}, {56,112,96}, 151d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{56,112,112}, {56,96,112}, 152d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{56,84,112}, {56,68,112}, 153d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{80,80,112}, {88,80,112}, 154d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{96,80,112}, {104,80,112}, 155d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{112,80,112}, {112,80,104}, 156d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{112,80,96}, {112,80,88}, /*160*/ 157d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{112,80,80}, {112,88,80}, 158d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{112,96,80}, {112,104,80}, 159d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{112,112,80}, {104,112,80}, 160d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{96,112,80}, {88,112,80}, 1615ff4eaf57b3cd47d0371f204f865cbba614674a0cristy{80,112,80}, {80,112,88}, 162d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{80,112,96}, {80,112,104}, 1637c9770650f31145e0fe8811d10b2e0ecd47697c8cristy{80,112,112}, {80,114,112}, 1647c9770650f31145e0fe8811d10b2e0ecd47697c8cristy{80,96,112}, {80,88,112}, /*176*/ 165d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{0,0,64}, {16,0,64}, 166d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{32,0,64}, {48,0,64}, 167d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,0,64}, {64,0,48}, 168d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,0,32}, {64,0,16}, 169d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,0,0}, {64,16,0}, 170d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,32,0}, {64,48,0}, 171d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,64,0}, {48,64,0}, 172d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{32,64,0}, {16,64,0}, /*192*/ 173d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{0,64,0}, {0,64,16}, 174d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{0,64,32}, {0,64,48}, 175d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{0,64,64}, {0,48,64}, 176d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{0,32,64}, {0,16,64}, 177d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{32,32,64}, {40,32,64}, 178d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{48,32,64}, {56,32,64}, 179d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,32,64}, {64,32,56}, 180d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,32,48}, {64,32,40}, /*208*/ 181d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,32,32}, {64,40,32}, 182d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,48,32}, {64,56,32}, 183d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,64,32}, {56,64,32}, 184d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{48,64,32}, {40,64,32}, 185d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{32,64,32}, {32,64,40}, 1865ff4eaf57b3cd47d0371f204f865cbba614674a0cristy{32,64,48}, {32,64,56}, 187d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{32,64,64}, {32,56,64}, 188d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{32,48,64}, {32,40,64}, /*224*/ 18904b11db5504ecdf205114ae7e9e68774a1ff0b9bcristy{44,44,64}, {48,44,64}, 1903d162a93f537cb7cbb6d9fa3b8e73e8f992a527acristy{52,44,64}, {60,44,64}, 191d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,44,64}, {64,44,60}, 192d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,44,52}, {64,44,48}, 193d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,44,44}, {64,48,44}, 194d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,52,44}, {64,60,44}, 195d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{64,64,44}, {60,64,44}, 196d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{52,64,44}, {48,64,44}, /*240*/ 197d7ecaca521e2840f1308b758f7b3a3a9fd2dce38cristy{44,64,44}, {44,64,48}, 1983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{44,64,52}, {44,64,60}, 1993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{44,64,64}, {44,60,64}, 2003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{44,55,64}, {44,48,64}, 2013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,0}, {0,0,0}, 2023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,0}, {0,0,0}, 2033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,0}, {0,0,0}, 2043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{0,0,0}, {0,0,0} /*256*/ 2053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}; 2063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 208528127ac76bc2eda65c7e8407b11669b25513149cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 209528127ac76bc2eda65c7e8407b11669b25513149cristy% % 210528127ac76bc2eda65c7e8407b11669b25513149cristy% % 211528127ac76bc2eda65c7e8407b11669b25513149cristy% % 212528127ac76bc2eda65c7e8407b11669b25513149cristy% I s W P G % 213528127ac76bc2eda65c7e8407b11669b25513149cristy% % 214528127ac76bc2eda65c7e8407b11669b25513149cristy% % 215528127ac76bc2eda65c7e8407b11669b25513149cristy% % 216528127ac76bc2eda65c7e8407b11669b25513149cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 217528127ac76bc2eda65c7e8407b11669b25513149cristy% 218528127ac76bc2eda65c7e8407b11669b25513149cristy% IsWPG() returns True if the image format type, identified by the magick 219528127ac76bc2eda65c7e8407b11669b25513149cristy% string, is WPG. 220528127ac76bc2eda65c7e8407b11669b25513149cristy% 221528127ac76bc2eda65c7e8407b11669b25513149cristy% The format of the IsWPG method is: 222528127ac76bc2eda65c7e8407b11669b25513149cristy% 223528127ac76bc2eda65c7e8407b11669b25513149cristy% unsigned int IsWPG(const unsigned char *magick,const size_t length) 224528127ac76bc2eda65c7e8407b11669b25513149cristy% 225528127ac76bc2eda65c7e8407b11669b25513149cristy% A description of each parameter follows: 226528127ac76bc2eda65c7e8407b11669b25513149cristy% 227528127ac76bc2eda65c7e8407b11669b25513149cristy% o status: Method IsWPG returns True if the image format type is WPG. 228528127ac76bc2eda65c7e8407b11669b25513149cristy% 229528127ac76bc2eda65c7e8407b11669b25513149cristy% o magick: compare image format pattern against these bytes. 230528127ac76bc2eda65c7e8407b11669b25513149cristy% 231528127ac76bc2eda65c7e8407b11669b25513149cristy% o length: Specifies the length of the magick string. 232528127ac76bc2eda65c7e8407b11669b25513149cristy% 233528127ac76bc2eda65c7e8407b11669b25513149cristy*/ 234528127ac76bc2eda65c7e8407b11669b25513149cristystatic unsigned int IsWPG(const unsigned char *magick,const size_t length) 235528127ac76bc2eda65c7e8407b11669b25513149cristy{ 236528127ac76bc2eda65c7e8407b11669b25513149cristy if (length < 4) 237528127ac76bc2eda65c7e8407b11669b25513149cristy return(MagickFalse); 238528127ac76bc2eda65c7e8407b11669b25513149cristy if (memcmp(magick,"\377WPC",4) == 0) 239528127ac76bc2eda65c7e8407b11669b25513149cristy return(MagickTrue); 240528127ac76bc2eda65c7e8407b11669b25513149cristy return(MagickFalse); 241528127ac76bc2eda65c7e8407b11669b25513149cristy} 242528127ac76bc2eda65c7e8407b11669b25513149cristy 243528127ac76bc2eda65c7e8407b11669b25513149cristy 244528127ac76bc2eda65c7e8407b11669b25513149cristystatic void Rd_WP_DWORD(Image *image,size_t *d) 245528127ac76bc2eda65c7e8407b11669b25513149cristy{ 246528127ac76bc2eda65c7e8407b11669b25513149cristy unsigned char 247528127ac76bc2eda65c7e8407b11669b25513149cristy b; 248528127ac76bc2eda65c7e8407b11669b25513149cristy 249528127ac76bc2eda65c7e8407b11669b25513149cristy b=ReadBlobByte(image); 250528127ac76bc2eda65c7e8407b11669b25513149cristy *d=b; 251528127ac76bc2eda65c7e8407b11669b25513149cristy if (b < 0xFFU) 252528127ac76bc2eda65c7e8407b11669b25513149cristy return; 253528127ac76bc2eda65c7e8407b11669b25513149cristy b=ReadBlobByte(image); 254528127ac76bc2eda65c7e8407b11669b25513149cristy *d=(size_t) b; 2553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b=ReadBlobByte(image); 2563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *d+=(size_t) b*256l; 2573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*d < 0x8000) 2585cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy return; 2595cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy *d=(*d & 0x7FFF) << 16; 2603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b=ReadBlobByte(image); 2613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *d+=(size_t) b; 2623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy b=ReadBlobByte(image); 2633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *d+=(size_t) b*256l; 2643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 2653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 2663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2675cbc016effaa2d7ee617f46ca0a2371533d4ae17cristystatic void InsertRow(Image *image,unsigned char *p,ssize_t y,int bpp, 2685cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ExceptionInfo *exception) 2693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 2703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 2715cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy bit; 2723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Quantum 274151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy index; 2753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register Quantum 2773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 2783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ssize_t 2803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 2813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (bpp) 2833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: /* Convert bitmap scanline. */ 2853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 2873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q == (Quantum *) NULL) 2883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 2893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < ((ssize_t) image->columns-7); x+=8) 2903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (bit=0; bit < 8; bit++) 2923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 293bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy index=((*p) & (0x80 >> bit) ? 0x01 : 0x00); 2943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 2953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 2963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 2973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 2993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 8) != 0) 3013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 302bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (bit=0; bit < (ssize_t) (image->columns % 8); bit++) 3035846039e7fade723e168819490eb771446e4b81fcristy { 3043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=((*p) & (0x80 >> bit) ? 0x01 : 0x00); 3053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 3063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 307e1c94d9d25db6b0dd7a5028ffee31d1057855d73cristy q+=GetPixelChannels(image); 3083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 3103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 311e1c94d9d25db6b0dd7a5028ffee31d1057855d73cristy if (!SyncAuthenticPixels(image,exception)) 3123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: /* Convert PseudoColor scanline. */ 3163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 3183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q == (Quantum *) NULL) 3193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < ((ssize_t) image->columns-3); x+=4) 3213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception); 323bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy SetPixelIndex(image,index,q); 3243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception); 3273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 3283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,exception); 3315cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy SetPixelIndex(image,index,q); 3323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3345cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy index=ConstrainColormapIndex(image,(*p) & 0x3,exception); 3353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 336a6400b1cfc3594644a0f02f3d77d920092f078eecristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3370c81d063030f7b30a97c7856e95534243cdc9e13cristy q+=GetPixelChannels(image); 3383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 3393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 4) != 0) 3413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception); 3433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 3443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 4) > 1) 3475cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy { 348bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception); 3495846039e7fade723e168819490eb771446e4b81fcristy SetPixelIndex(image,index,q); 3503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 4) > 2) 3533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 2) & 0x3, 3553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy exception); 3563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 3573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 3623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (SyncAuthenticPixels(image,exception) == MagickFalse) 3643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: /* Convert PseudoColor scanline. */ 3693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 3713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q == (Quantum *) NULL) 3723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < ((ssize_t) image->columns-1); x+=2) 3743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception); 3763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 3773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p) & 0x0f,exception); 3803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 3813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 3833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->columns % 2) != 0) 3863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception); 3883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 3893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 3903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 3913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 3923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (SyncAuthenticPixels(image,exception) == MagickFalse) 3943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 3963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: /* Convert PseudoColor scanline. */ 3983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 4003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q == (Quantum *) NULL) break; 4017096f1cf18bfd18730112b4783146547a97854dacristy 4023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (ssize_t) image->columns; x++) 4033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=ConstrainColormapIndex(image,*p,exception); 4053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelIndex(image,index,q); 4063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q); 4073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 4083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 4093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (SyncAuthenticPixels(image,exception) == MagickFalse) 4113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41570aa59ba920fd758a05dfd1e59a446638b3dd2a9Cristy case 24: /* Convert DirectColor scanline. */ 4163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); 4173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q == (Quantum *) NULL) 4183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (ssize_t) image->columns; x++) 4203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelRed(image,ScaleCharToQuantum(*p++),q); 4223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 4233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 4243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=GetPixelChannels(image); 4253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!SyncAuthenticPixels(image,exception)) 4273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4297096f1cf18bfd18730112b4783146547a97854dacristy } 4303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 4313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* Helper for WPG1 raster reader. */ 4343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define InsertByte(b) \ 4353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \ 4363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff[x]=b; \ 4373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x++; \ 4383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if((ssize_t) x>=ldblk) \ 4393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { \ 4403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertRow(image,BImgBuff,(ssize_t) y,bpp,exception); \ 4413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; \ 4423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; \ 4433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } \ 4443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 4453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* WPG1 raster reader. */ 4463ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int UnpackWPGRaster(Image *image,int bpp,ExceptionInfo *exception) 4473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 4483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 4493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 4503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y, 4513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 4523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 4543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf, 4553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *BImgBuff, 4563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount; 4573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ssize_t 4593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk; 4603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 4623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 4633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk=(ssize_t) ((bpp*image->columns+7)/8); 4653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk, 4663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8*sizeof(*BImgBuff)); 4673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BImgBuff==NULL) return(-2); 4683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while(y<(ssize_t) image->rows) 4703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 4723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c; 4733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c=ReadBlobByte(image); 4753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (c == EOF) 4763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=(unsigned char) c; 4783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=bbuf & 0x7F; 4793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(bbuf & 0x80) 4803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(RunCount) /* repeat next byte runcount * */ 4823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 4843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i<(int) RunCount;i++) InsertByte(bbuf); 4853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else { /* read next byte as RunCount; repeat 0xFF runcount* */ 4873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c=ReadBlobByte(image); 4883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (c < 0) 4893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 4903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=(unsigned char) c; 4913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i<(int) RunCount;i++) InsertByte(0xFF); 4923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4944c08aed51c5899665ade97263692328eea4af106cristy else { 4953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(RunCount) /* next runcount byte are readed directly */ 4963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i < (int) RunCount;i++) 4983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 5003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertByte(bbuf); 5013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else { /* repeat previous line runcount* */ 5043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c=ReadBlobByte(image); 5053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (c < 0) 5063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 507151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy RunCount=(unsigned char) c; 508dcc02b0a70d924b55afa7ce2089c4c15b25f2e1fcristy if(x) { /* attempt to duplicate row from x position: */ 5093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* I do not know what to do here */ 510018f07f7333b25743d0afff892450cebdb905c1acristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 5113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-3); 5123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i < (int) RunCount;i++) 5143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 515151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy x=0; 516a8549b176173db7680652304c372c64bb1a51737cristy y++; /* Here I need to duplicate previous row RUNCOUNT* */ 5173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(y<2) continue; 5183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(y>(ssize_t) image->rows) 5193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 5213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-4); 522018f07f7333b25743d0afff892450cebdb905c1acristy } 5233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertRow(image,BImgBuff,y-1,bpp,exception); 5243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (EOFBlob(image) != MagickFalse) 5283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 5293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 530018f07f7333b25743d0afff892450cebdb905c1acristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 5313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(y <(ssize_t) image->rows ? -5 : 0); 5323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 5333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5355cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy/* Helper for WPG2 reader. */ 5363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define InsertByte6(b) \ 5373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \ 5383ed852eea50f9d4cd633efb8c2b054b8e33c253cristyDisableMSCWarning(4310) \ 5393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(XorMe)\ 5403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff[x] = (unsigned char)~b;\ 5413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else\ 5423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff[x] = b;\ 543018f07f7333b25743d0afff892450cebdb905c1acristyRestoreMSCWarning \ 5443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x++; \ 5453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if((ssize_t) x >= ldblk) \ 5463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { \ 5473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertRow(image,BImgBuff,(ssize_t) y,bpp,exception); \ 5483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; \ 5493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; \ 5503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } \ 5513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 5523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* WPG2 raster reader. */ 5533ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int UnpackWPG2Raster(Image *image,int bpp,ExceptionInfo *exception) 5543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 5553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 5563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount, 5573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XorMe = 0; 5583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t 5603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 5613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 5623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ssize_t 5643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 5653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk; 5663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 5683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy SampleSize=1; 5693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 5713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf, 5723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *BImgBuff, 573bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy SampleBuffer[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 5745cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy 5755cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy x=0; 5763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 5773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk=(ssize_t) ((bpp*image->columns+7)/8); 5783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk, 5793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*BImgBuff)); 5803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BImgBuff==NULL) 5813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(-2); 5823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5836b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy while( y< image->rows) 5846b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy { 5853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 5863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5876b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy switch(bbuf) 5886b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy { 5895cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy case 0x7D: 5905cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy SampleSize=ReadBlobByte(image); /* DSZ */ 5913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(SampleSize>8) 592bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy return(-2); 5935cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy if(SampleSize<1) 5945cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy return(-2); 5953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 59674966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy case 0x7E: 59774966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy (void) FormatLocaleFile(stderr, 59874966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy "\nUnsupported WPG token XOR, please report!"); 5993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XorMe=!XorMe; 60020aa2994f8d56f6f03a7a96b2a25d93b906989bcCristy break; 6013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x7F: 6023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=ReadBlobByte(image); /* BLK */ 6033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (RunCount < 0) 6043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0; i < SampleSize*(RunCount+1); i++) 6063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertByte6(0); 608bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy } 6093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0xFD: 611bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy RunCount=ReadBlobByte(image); /* EXT */ 6123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (RunCount < 0) 6133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6146193b86c0b59030b647a10c75f37ec82d73e3695cristy for(i=0; i<= RunCount;i++) 6156193b86c0b59030b647a10c75f37ec82d73e3695cristy for(bbuf=0; bbuf < SampleSize; bbuf++) 6166193b86c0b59030b647a10c75f37ec82d73e3695cristy InsertByte6(SampleBuffer[bbuf]); 61720aa2994f8d56f6f03a7a96b2a25d93b906989bcCristy break; 61874966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy case 0xFE: 6193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=ReadBlobByte(image); /* RST */ 6203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (RunCount < 0) 6213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(x!=0) 62320aa2994f8d56f6f03a7a96b2a25d93b906989bcCristy { 6243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) FormatLocaleFile(stderr, 62520aa2994f8d56f6f03a7a96b2a25d93b906989bcCristy "\nUnsupported WPG2 unaligned token RST x=%.20g, please report!\n" 62620aa2994f8d56f6f03a7a96b2a25d93b906989bcCristy ,(double) x); 6272911f2d54257d36e1086061dbcc312fdad781070cristy return(-3); 628e2c81adf02cbe4bb92991389437a2a1daf8ed313cristy } 629bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy { 6303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* duplicate the previous row RunCount x */ 6313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0;i<=RunCount;i++) 6325cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy { 6333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertRow(image,BImgBuff,(ssize_t) (image->rows >= y ? y : image->rows-1), 6343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp,exception); 63578fed5ea9a7f0a35e641ce3bc6f835fb099c4d20cristy y++; 63674966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy } 6376193b86c0b59030b647a10c75f37ec82d73e3695cristy } 63874966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy break; 6394aa314e7f9e09c30fcedcd112156b1dfb712b62dcristy case 0xFF: 6403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=ReadBlobByte(image); /* WHT */ 6413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (RunCount < 0) 6423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for(i=0; i < SampleSize*(RunCount+1); i++) 6443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6454aa314e7f9e09c30fcedcd112156b1dfb712b62dcristy InsertByte6(0xFF); 6466b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy } 6476b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy break; 6486b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy default: 6493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RunCount=bbuf & 0x7F; 6506b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy 6516b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy if(bbuf & 0x80) /* REP */ 6526b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy { 6536b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy for(i=0; i < SampleSize; i++) 6546b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy SampleBuffer[i]=ReadBlobByte(image); 6556b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy for(i=0;i<=RunCount;i++) 6566b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy for(bbuf=0;bbuf<SampleSize;bbuf++) 6576b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy InsertByte6(SampleBuffer[bbuf]); 6586b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy } 6596b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy else { /* NRP */ 6606b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy for(i=0; i< SampleSize*(RunCount+1);i++) 6616b1d05e71aed91c7f85ff155dfad281e24d16fe5cristy { 6623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bbuf=ReadBlobByte(image); 6636193b86c0b59030b647a10c75f37ec82d73e3695cristy InsertByte6(bbuf); 6643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66574966dbfe99011d1f7bea577e97a3d9a7b9836c7cristy } 6666193b86c0b59030b647a10c75f37ec82d73e3695cristy } 6673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (EOFBlob(image) != MagickFalse) 6683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6696193b86c0b59030b647a10c75f37ec82d73e3695cristy } 6706193b86c0b59030b647a10c75f37ec82d73e3695cristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 6713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 6723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 6733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6753ed852eea50f9d4cd633efb8c2b054b8e33c253cristytypedef float tCTM[3][3]; 6763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6773ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic unsigned LoadWPG2Flags(Image *image,char Precision,float *Angle,tCTM *CTM) 6783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 6793ed852eea50f9d4cd633efb8c2b054b8e33c253cristyconst unsigned char TPR=1,TRN=2,SKW=4,SCL=8,ROT=0x10,OID=0x20,LCK=0x80; 6803ed852eea50f9d4cd633efb8c2b054b8e33c253cristyssize_t x; 6813ed852eea50f9d4cd633efb8c2b054b8e33c253cristyunsigned DenX; 6823ed852eea50f9d4cd633efb8c2b054b8e33c253cristyunsigned Flags; 6833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) memset(*CTM,0,sizeof(*CTM)); /*CTM.erase();CTM.resize(3,3);*/ 6853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[0][0]=1; 6863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[1][1]=1; 6873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[2][2]=1; 6883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Flags=ReadBlobLSBShort(image); 6903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & LCK) (void) ReadBlobLSBLong(image); /*Edit lock*/ 6913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & OID) 6923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Precision==0) 6943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy {(void) ReadBlobLSBShort(image);} /*ObjectID*/ 6953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 6963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy {(void) ReadBlobLSBLong(image);} /*ObjectID (Double precision)*/ 6973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & ROT) 6993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Rot Angle*/ 7013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Angle) *Angle=x/65536.0; 7023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & (ROT|SCL)) 7043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Sx*cos()*/ 7063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[0][0] = (float)x/0x10000; 7073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Sy*cos()*/ 7083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[1][1] = (float)x/0x10000; 7095cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy } 7103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & (ROT|SKW)) 7113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Kx*sin()*/ 7133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[1][0] = (float)x/0x10000; 7143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); /*Ky*sin()*/ 7153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[0][1] = (float)x/0x10000; 7163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & TRN) 7183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7195cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy x=ReadBlobLSBLong(image); DenX=ReadBlobLSBShort(image); /*Tx*/ 7205cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy if(x>=0) (*CTM)[0][2] = (float)x+(float)DenX/0x10000; 7213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else (*CTM)[0][2] = (float)x-(float)DenX/0x10000; 7223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBLong(image); DenX=ReadBlobLSBShort(image); /*Ty*/ 7235cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy (*CTM)[1][2]=(float)x + ((x>=0)?1:-1)*(float)DenX/0x10000; 7243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(x>=0) (*CTM)[1][2] = (float)x+(float)DenX/0x10000; 7253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else (*CTM)[1][2] = (float)x-(float)DenX/0x10000; 7263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Flags & TPR) 7283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBShort(image); DenX=ReadBlobLSBShort(image); /*Px*/ 7303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[2][0] = x + (float)DenX/0x10000;; 7313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ReadBlobLSBShort(image); DenX=ReadBlobLSBShort(image); /*Py*/ 7323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*CTM)[2][1] = x + (float)DenX/0x10000; 7333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 734bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy return(Flags); 7353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 7363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7383ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Image *ExtractPostscript(Image *image,const ImageInfo *image_info, 7393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickOffsetType PS_Offset,ssize_t PS_Size,ExceptionInfo *exception) 7403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 741e1c94d9d25db6b0dd7a5028ffee31d1057855d73cristy char 7423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy postscript_file[MagickPathExtent]; 7433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const MagicInfo 7453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *magic_info; 746e1c94d9d25db6b0dd7a5028ffee31d1057855d73cristy 7473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FILE 7483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ps_file; 7493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ImageInfo 7513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *clone_info; 7523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 7543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image2; 7553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 7573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick[2*MagickPathExtent]; 758024843f38984cd26602f0b3b28a0768dfa056bb5cristy 7593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((clone_info=CloneImageInfo(image_info)) == NULL) 7613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 7623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy clone_info->blob=(void *) NULL; 7633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy clone_info->length=0; 7643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7655cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy /* Obtain temporary file */ 7663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) AcquireUniqueFilename(postscript_file); 7673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ps_file=fopen_utf8(postscript_file,"wb"); 7683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ps_file == (FILE *) NULL) 7693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto FINISH; 7705cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy 7713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Copy postscript to temporary file */ 7723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SeekBlob(image,PS_Offset,SEEK_SET); 7733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ReadBlob(image, 2*MagickPathExtent, magick); 774e2c81adf02cbe4bb92991389437a2a1daf8ed313cristy 775e2c81adf02cbe4bb92991389437a2a1daf8ed313cristy (void) SeekBlob(image,PS_Offset,SEEK_SET); 7763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while(PS_Size-- > 0) 7773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) fputc(ReadBlobByte(image),ps_file); 7793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) fclose(ps_file); 7813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Detect file format - Check magic.mgk configuration file. */ 7833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magic_info=GetMagicInfo(magick,2*MagickPathExtent,exception); 7843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(magic_info == (const MagicInfo *) NULL) goto FINISH_UNL; 7853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* printf("Detected:%s \n",magic_info->name); */ 7863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(exception->severity != UndefinedException) goto FINISH_UNL; 7873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(magic_info->name == (char *) NULL) goto FINISH_UNL; 7883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) strncpy(clone_info->magick,magic_info->name,MagickPathExtent); 7903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Read nested image */ 7923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /*FormatString(clone_info->filename,"%s:%s",magic_info->name,postscript_file);*/ 7933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FormatLocaleString(clone_info->filename,MagickPathExtent,"%s",postscript_file); 7943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image2=ReadImage(clone_info,exception); 7953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!image2) 7973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto FINISH_UNL; 7983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 8003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Replace current image with new image while copying base image 8013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy attributes. 8023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(image2->filename,image->filename,MagickPathExtent); 8043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(image2->magick_filename,image->magick_filename,MagickPathExtent); 8053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(image2->magick,image->magick,MagickPathExtent); 8063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image2->depth=image->depth; 8073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DestroyBlob(image2); 8083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image2->blob=ReferenceBlob(image->blob); 8093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->rows == 0) || (image->columns == 0)) 8113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DeleteImageFromList(&image); 8123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,image2); 8143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FINISH_UNL: 8163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RelinquishUniqueFileResource(postscript_file); 8173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FINISH: 8183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DestroyImageInfo(clone_info); 8193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 8205cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy} 8213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 8233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% R e a d W P G I m a g e % 8283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8305cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% % 8315cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Method ReadWPGImage reads an WPG X image file and returns it. It 8345cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% allocates the memory necessary for the new Image structure and returns a 8353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% pointer to the new image. 8363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the ReadWPGImage method is: 8383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Image *ReadWPGImage(const ImageInfo *image_info,ExceptionInfo *exception) 8403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 8423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: Method ReadWPGImage returns a pointer to the image after 8443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% reading. A null image is returned if there is a memory shortage or if 8453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the image cannot be read. 846e1c94d9d25db6b0dd7a5028ffee31d1057855d73cristy% 8473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image_info: Specifies a pointer to a ImageInfo structure. 8483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o exception: return any errors or warnings in this structure. 8503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 851e1c94d9d25db6b0dd7a5028ffee31d1057855d73cristy*/ 8523ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Image *ReadWPGImage(const ImageInfo *image_info, 8533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExceptionInfo *exception) 854024843f38984cd26602f0b3b28a0768dfa056bb5cristy{ 8553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t FileId; 8585cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy MagickOffsetType DataOffset; 8593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int ProductType; 8603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int FileType; 861e7f5109f30fc7242d04a26174a9138483dda5b6acristy unsigned char MajorVersion; 862a8549b176173db7680652304c372c64bb1a51737cristy unsigned char MinorVersion; 863e7f5109f30fc7242d04a26174a9138483dda5b6acristy unsigned int EncryptKey; 8643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Reserved; 8653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGHeader; 8664c08aed51c5899665ade97263692328eea4af106cristy 8674c08aed51c5899665ade97263692328eea4af106cristy typedef struct 8683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char RecType; 8703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t RecordLength; 8713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGRecord; 8723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char Class; 8763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char RecType; 8773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t Extension; 8783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t RecordLength; 8793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPG2Record; 8803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned HorizontalUnits; 8843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned VerticalUnits; 8853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char PosSizePrecision; 8863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPG2Start; 8873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8905cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy unsigned int Width; 8913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Height; 8923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Depth; 8933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int HorzRes; 8943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int VertRes; 8953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGBitmapType1; 8963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 8983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Width; 9003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Height; 9013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char Depth; 9025cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy unsigned char Compression; 9035cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy } WPG2BitmapType1; 9043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 9065cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy { 9073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int RotAngle; 9083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int LowLeftX; 9093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int LowLeftY; 9103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int UpRightX; 9113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int UpRightY; 9123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Width; 9133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Height; 9143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int Depth; 9153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int HorzRes; 9163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int VertRes; 9173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGBitmapType2; 9183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct 9203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int StartIndex; 9223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int NumOfEntries; 9235cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy } WPGColorMapRec; 9243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct { 9275cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy size_t PS_unknown1; 9283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int PS_unknown2; 9293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int PS_unknown3; 9303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WPGPSl1Record; 9315cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy */ 9323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 9345cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy *image; 9353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9365cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy unsigned int 937efe601ce9ea5ad34ad0e8ad6e61d9be9b148b2a3cristy status; 9383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPGHeader 9403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header; 9413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPGRecord 9435cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy Rec; 9443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9455cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy WPG2Record 946efe601ce9ea5ad34ad0e8ad6e61d9be9b148b2a3cristy Rec2; 9473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG2Start StartWPG; 949d984f27fbbb96073787c88f4c9409d7f836cedc5cristy 9505cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy WPGBitmapType1 951d984f27fbbb96073787c88f4c9409d7f836cedc5cristy BitmapHeader1; 952cbb34a4def108d6db032ca9631a433afd3ea5a5dcristy 9535cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy WPG2BitmapType1 9543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Bitmap2Header1; 955704acaaebbfeec018847456e79de0ce301db126ecristy 9565cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy WPGBitmapType2 957704acaaebbfeec018847456e79de0ce301db126ecristy BitmapHeader2; 9586193b86c0b59030b647a10c75f37ec82d73e3695cristy 9595cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy WPGColorMapRec 9606193b86c0b59030b647a10c75f37ec82d73e3695cristy WPG_Palette; 9613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9625cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy int 9633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 9645cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy bpp, 965704acaaebbfeec018847456e79de0ce301db126ecristy WPG2Flags; 9663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9675cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ssize_t 9685cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy ldblk; 9693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t 9713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy one; 9723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 9743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *BImgBuff; 9753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy tCTM CTM; /*current transform matrix*/ 9775cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy 9785cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy /* 9793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Open image file. 9803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info != (const ImageInfo *) NULL); 9823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info->signature == MagickCoreSignature); 9833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(exception != (ExceptionInfo *) NULL); 9843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(exception->signature == MagickCoreSignature); 9853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy one=1; 9863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=AcquireImage(image_info,exception); 9873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->depth=8; 9883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); 9893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == MagickFalse) 9903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=DestroyImageList(image); 9923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 9933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Read WPG image. 9963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.FileId=ReadBlobLSBLong(image); 9983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.DataOffset=(MagickOffsetType) ReadBlobLSBLong(image); 9993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.ProductType=ReadBlobLSBShort(image); 10005cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy Header.FileType=ReadBlobLSBShort(image); 10015cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy Header.MajorVersion=ReadBlobByte(image); 10023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.MinorVersion=ReadBlobByte(image); 10033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.EncryptKey=ReadBlobLSBShort(image); 10043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.Reserved=ReadBlobLSBShort(image); 10053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (Header.FileId!=0x435057FF || (Header.ProductType>>8)!=0x16) 10073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CorruptImageError,"ImproperImageHeader"); 10083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (Header.EncryptKey!=0) 10093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CoderError,"EncryptedWPGImageFileNotSupported"); 10103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns = 1; 10123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->rows = 1; 10133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors = 0; 10143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=0; 10155cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy BitmapHeader2.RotAngle=0; 10165cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy 10173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Header.FileType) 10183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: /* WPG level 1 */ 10202857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy while(!EOFBlob(image)) /* object parser loop */ 102187dc5e4e6f9471304ba85f508de30e664b484d3aCristy { 102287dc5e4e6f9471304ba85f508de30e664b484d3aCristy (void) SeekBlob(image,Header.DataOffset,SEEK_SET); 102387dc5e4e6f9471304ba85f508de30e664b484d3aCristy if(EOFBlob(image)) 102469a0d3b5699c573f650e6b61f98ce4579d6f218cCristy break; 102517f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy 10260d88ea3545d808eae9feeacdd57eec41db18d2baCristy Rec.RecType=(i=ReadBlobByte(image)); 10270d88ea3545d808eae9feeacdd57eec41db18d2baCristy if(i==EOF) 10280d88ea3545d808eae9feeacdd57eec41db18d2baCristy break; 102917f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy Rd_WP_DWORD(image,&Rec.RecordLength); 103017f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy if(EOFBlob(image)) 103117f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy break; 103217f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy 103317f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy Header.DataOffset=TellBlob(image)+Rec.RecordLength; 103417f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy 103587dc5e4e6f9471304ba85f508de30e664b484d3aCristy switch(Rec.RecType) 103687dc5e4e6f9471304ba85f508de30e664b484d3aCristy { 103787dc5e4e6f9471304ba85f508de30e664b484d3aCristy case 0x0B: /* bitmap type 1 */ 10386720ed7fdc6908b46f213f43c316fcccab53dbcdCristy BitmapHeader1.Width=ReadBlobLSBShort(image); 10396720ed7fdc6908b46f213f43c316fcccab53dbcdCristy BitmapHeader1.Height=ReadBlobLSBShort(image); 104087dc5e4e6f9471304ba85f508de30e664b484d3aCristy if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Height == 0)) 10416720ed7fdc6908b46f213f43c316fcccab53dbcdCristy ThrowReaderException(CorruptImageError,"ImproperImageHeader"); 10420d88ea3545d808eae9feeacdd57eec41db18d2baCristy BitmapHeader1.Depth=ReadBlobLSBShort(image); 104317f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy BitmapHeader1.HorzRes=ReadBlobLSBShort(image); 104417f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy BitmapHeader1.VertRes=ReadBlobLSBShort(image); 10450d88ea3545d808eae9feeacdd57eec41db18d2baCristy 104617f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy if(BitmapHeader1.HorzRes && BitmapHeader1.VertRes) 104787dc5e4e6f9471304ba85f508de30e664b484d3aCristy { 104817f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy image->units=PixelsPerCentimeterResolution; 10490d88ea3545d808eae9feeacdd57eec41db18d2baCristy image->resolution.x=BitmapHeader1.HorzRes/470.0; 105017f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy image->resolution.y=BitmapHeader1.VertRes/470.0; 10510d88ea3545d808eae9feeacdd57eec41db18d2baCristy } 10520d88ea3545d808eae9feeacdd57eec41db18d2baCristy image->columns=BitmapHeader1.Width; 105317f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy image->rows=BitmapHeader1.Height; 105417f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy bpp=BitmapHeader1.Depth; 105517f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy 105617f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy goto UnpackRaster; 105717f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy 105817f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy case 0x0E: /*Color palette */ 105917f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy WPG_Palette.StartIndex=ReadBlobLSBShort(image); 106017f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); 106117f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy 106217f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy image->colors=WPG_Palette.NumOfEntries; 106387dc5e4e6f9471304ba85f508de30e664b484d3aCristy if (!AcquireImageColormap(image,image->colors,exception)) 106487dc5e4e6f9471304ba85f508de30e664b484d3aCristy goto NoMemory; 106587dc5e4e6f9471304ba85f508de30e664b484d3aCristy for (i=WPG_Palette.StartIndex; 106617f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy i < (int)WPG_Palette.NumOfEntries; i++) 106717f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy { 106887dc5e4e6f9471304ba85f508de30e664b484d3aCristy image->colormap[i].red=ScaleCharToQuantum((unsigned char) 10690d88ea3545d808eae9feeacdd57eec41db18d2baCristy ReadBlobByte(image)); 10700d88ea3545d808eae9feeacdd57eec41db18d2baCristy image->colormap[i].green=ScaleCharToQuantum((unsigned char) 107117f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy ReadBlobByte(image)); 10720d88ea3545d808eae9feeacdd57eec41db18d2baCristy image->colormap[i].blue=ScaleCharToQuantum((unsigned char) 10730d88ea3545d808eae9feeacdd57eec41db18d2baCristy ReadBlobByte(image)); 10740d88ea3545d808eae9feeacdd57eec41db18d2baCristy } 10750d88ea3545d808eae9feeacdd57eec41db18d2baCristy break; 10760d88ea3545d808eae9feeacdd57eec41db18d2baCristy 107717f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy case 0x11: /* Start PS l1 */ 107817f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy if(Rec.RecordLength > 8) 107917f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy image=ExtractPostscript(image,image_info, 10800d88ea3545d808eae9feeacdd57eec41db18d2baCristy TellBlob(image)+8, /* skip PS header in the wpg */ 108117f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy (ssize_t) Rec.RecordLength-8,exception); 10826720ed7fdc6908b46f213f43c316fcccab53dbcdCristy break; 108317f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy 108417f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy case 0x14: /* bitmap type 2 */ 10856720ed7fdc6908b46f213f43c316fcccab53dbcdCristy BitmapHeader2.RotAngle=ReadBlobLSBShort(image); 108617f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy BitmapHeader2.LowLeftX=ReadBlobLSBShort(image); 108717f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy BitmapHeader2.LowLeftY=ReadBlobLSBShort(image); 10886720ed7fdc6908b46f213f43c316fcccab53dbcdCristy BitmapHeader2.UpRightX=ReadBlobLSBShort(image); 108917f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy BitmapHeader2.UpRightY=ReadBlobLSBShort(image); 109017f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy BitmapHeader2.Width=ReadBlobLSBShort(image); 10916720ed7fdc6908b46f213f43c316fcccab53dbcdCristy BitmapHeader2.Height=ReadBlobLSBShort(image); 109217f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Height == 0)) 109317f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy ThrowReaderException(CorruptImageError,"ImproperImageHeader"); 10946720ed7fdc6908b46f213f43c316fcccab53dbcdCristy BitmapHeader2.Depth=ReadBlobLSBShort(image); 10950d88ea3545d808eae9feeacdd57eec41db18d2baCristy BitmapHeader2.HorzRes=ReadBlobLSBShort(image); 10960d88ea3545d808eae9feeacdd57eec41db18d2baCristy BitmapHeader2.VertRes=ReadBlobLSBShort(image); 10970d88ea3545d808eae9feeacdd57eec41db18d2baCristy 10980d88ea3545d808eae9feeacdd57eec41db18d2baCristy image->units=PixelsPerCentimeterResolution; 10990d88ea3545d808eae9feeacdd57eec41db18d2baCristy image->page.width=(unsigned int) 11000d88ea3545d808eae9feeacdd57eec41db18d2baCristy ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightX)/470.0); 11010d88ea3545d808eae9feeacdd57eec41db18d2baCristy image->page.height=(unsigned int) 110217f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy ((BitmapHeader2.LowLeftX-BitmapHeader2.UpRightY)/470.0); 110317f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy image->page.x=(int) (BitmapHeader2.LowLeftX/470.0); 11040d88ea3545d808eae9feeacdd57eec41db18d2baCristy image->page.y=(int) (BitmapHeader2.LowLeftX/470.0); 11056720ed7fdc6908b46f213f43c316fcccab53dbcdCristy if(BitmapHeader2.HorzRes && BitmapHeader2.VertRes) 110614c8ae4cf8fdcb1c1ed0f8fd1a5c3290414fe733Cristy { 110787dc5e4e6f9471304ba85f508de30e664b484d3aCristy image->resolution.x=BitmapHeader2.HorzRes/470.0; 110887dc5e4e6f9471304ba85f508de30e664b484d3aCristy image->resolution.y=BitmapHeader2.VertRes/470.0; 110987dc5e4e6f9471304ba85f508de30e664b484d3aCristy } 111069a0d3b5699c573f650e6b61f98ce4579d6f218cCristy image->columns=BitmapHeader2.Width; 111169a0d3b5699c573f650e6b61f98ce4579d6f218cCristy image->rows=BitmapHeader2.Height; 111269a0d3b5699c573f650e6b61f98ce4579d6f218cCristy bpp=BitmapHeader2.Depth; 111369a0d3b5699c573f650e6b61f98ce4579d6f218cCristy 111469a0d3b5699c573f650e6b61f98ce4579d6f218cCristy UnpackRaster: 111569a0d3b5699c573f650e6b61f98ce4579d6f218cCristy status=SetImageExtent(image,image->columns,image->rows,exception); 111669a0d3b5699c573f650e6b61f98ce4579d6f218cCristy if (status == MagickFalse) 111769a0d3b5699c573f650e6b61f98ce4579d6f218cCristy break; 111869a0d3b5699c573f650e6b61f98ce4579d6f218cCristy if ((image->colors == 0) && (bpp != 24)) 111991c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy { 11209da9d9c28f5574cc630eb8d8a48186f4951c4e33Cristy image->colors=one << bpp; 112191c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy if (!AcquireImageColormap(image,image->colors,exception)) 11220d88ea3545d808eae9feeacdd57eec41db18d2baCristy { 112317f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy NoMemory: 112469a0d3b5699c573f650e6b61f98ce4579d6f218cCristy ThrowReaderException(ResourceLimitError, 112569a0d3b5699c573f650e6b61f98ce4579d6f218cCristy "MemoryAllocationFailed"); 1126d45bfbb9ef2f6b90eb038b56d1a416b59c68abe0shamsa } 1127d45bfbb9ef2f6b90eb038b56d1a416b59c68abe0shamsa /* printf("Load default colormap \n"); */ 112869a0d3b5699c573f650e6b61f98ce4579d6f218cCristy for (i=0; (i < (int) image->colors) && (i < 256); i++) 112987dc5e4e6f9471304ba85f508de30e664b484d3aCristy { 113091c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy image->colormap[i].red=ScaleCharToQuantum(WPG1_Palette[i].Red); 113191c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy image->colormap[i].green=ScaleCharToQuantum(WPG1_Palette[i].Green); 113291c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy image->colormap[i].blue=ScaleCharToQuantum(WPG1_Palette[i].Blue); 113369a0d3b5699c573f650e6b61f98ce4579d6f218cCristy } 113469a0d3b5699c573f650e6b61f98ce4579d6f218cCristy } 113569a0d3b5699c573f650e6b61f98ce4579d6f218cCristy else 113669a0d3b5699c573f650e6b61f98ce4579d6f218cCristy { 113750d31568365a106c91ca4e827757fc2c806c6b16Cristy if (bpp < 24) 113869a0d3b5699c573f650e6b61f98ce4579d6f218cCristy if ( (image->colors < (one << bpp)) && (bpp != 24) ) 113906d4a5a39532c883052f98c8e870d015be8db1ccCristy image->colormap=(PixelInfo *) ResizeQuantumMemory( 114006d4a5a39532c883052f98c8e870d015be8db1ccCristy image->colormap,(size_t) (one << bpp), 114169a0d3b5699c573f650e6b61f98ce4579d6f218cCristy sizeof(*image->colormap)); 114287dc5e4e6f9471304ba85f508de30e664b484d3aCristy } 114387dc5e4e6f9471304ba85f508de30e664b484d3aCristy 114469a0d3b5699c573f650e6b61f98ce4579d6f218cCristy if (bpp == 1) 114591c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy { 114691c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy if(image->colormap[0].red==0 && 114791c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy image->colormap[0].green==0 && 1148d45bfbb9ef2f6b90eb038b56d1a416b59c68abe0shamsa image->colormap[0].blue==0 && 114991c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy image->colormap[1].red==0 && 115069a0d3b5699c573f650e6b61f98ce4579d6f218cCristy image->colormap[1].green==0 && 115169a0d3b5699c573f650e6b61f98ce4579d6f218cCristy image->colormap[1].blue==0) 115214c8ae4cf8fdcb1c1ed0f8fd1a5c3290414fe733Cristy { /* fix crippled monochrome palette */ 115369a0d3b5699c573f650e6b61f98ce4579d6f218cCristy image->colormap[1].red = 115469a0d3b5699c573f650e6b61f98ce4579d6f218cCristy image->colormap[1].green = 11553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[1].blue = QuantumRange; 11563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(UnpackWPGRaster(image,bpp,exception) < 0) 11603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* The raster cannot be unpacked */ 11613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1162151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy DecompressionFailed: 11633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CoderError,"UnableToDecompressImage"); 11643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11659c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy 11669c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy if(Rec.RecType==0x14 && BitmapHeader2.RotAngle!=0 && !image_info->ping) 11679c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy { 11683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* flop command */ 11693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BitmapHeader2.RotAngle & 0x8000) 11703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 11723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *flop_image; 11733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flop_image = FlopImage(image, exception); 11753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (flop_image != (Image *) NULL) { 11763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(flop_image,image); 11773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 1178151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy AppendImageToList(&image,flop_image); 11793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 11819c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy /* flip command */ 11829c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy if(BitmapHeader2.RotAngle & 0x2000) 11833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 11853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *flip_image; 11863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flip_image = FlipImage(image, exception); 11883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (flip_image != (Image *) NULL) { 11893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(flip_image,image); 11903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 11913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,flip_image); 11923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 1193151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy } 11943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* rotate command */ 11953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BitmapHeader2.RotAngle & 0x0FFF) 11969c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy { 11979c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy Image 11983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *rotate_image; 11993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotate_image=RotateImage(image,(BitmapHeader2.RotAngle & 12013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x0FFF), exception); 12023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (rotate_image != (Image *) NULL) { 12033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(rotate_image,image); 12043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 12053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,rotate_image); 12063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 1209151b66dffc9e3c2e8c4f8cdaca37ff987ca0f497cristy 12103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Allocate next image structure. */ 12113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AcquireNextImage(image_info,image,exception); 12129c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy image->depth=8; 12139c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy if (image->next == (Image *) NULL) 12149c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy goto Finish; 12153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=SyncNextImageInList(image); 12163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns=image->rows=1; 12173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors=0; 12183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12205cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy case 0x1B: /* Postscript l2 */ 12215cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy if(Rec.RecordLength>0x3C) 12223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=ExtractPostscript(image,image_info, 12233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy TellBlob(image)+0x3C, /* skip PS l2 header in the wpg */ 12243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ssize_t) Rec.RecordLength-0x3C,exception); 12253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: /* WPG level 2 */ 12313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) memset(CTM,0,sizeof(CTM)); 12323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StartWPG.PosSizePrecision = 0; 12333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while(!EOFBlob(image)) /* object parser loop */ 12343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SeekBlob(image,Header.DataOffset,SEEK_SET); 12363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(EOFBlob(image)) 12373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rec2.Class=(i=ReadBlobByte(image)); 12403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(i==EOF) 12413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rec2.RecType=(i=ReadBlobByte(image)); 12433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(i==EOF) 12443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rd_WP_DWORD(image,&Rec2.Extension); 12463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rd_WP_DWORD(image,&Rec2.RecordLength); 12473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(EOFBlob(image)) 12483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Header.DataOffset=TellBlob(image)+Rec2.RecordLength; 12513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Rec2.RecType) 12533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 1255f8f295fde25dd8b1a50470d53b641d5265c0871fcristy StartWPG.HorizontalUnits=ReadBlobLSBShort(image); 12563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StartWPG.VerticalUnits=ReadBlobLSBShort(image); 12573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StartWPG.PosSizePrecision=ReadBlobByte(image); 12583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 12593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x0C: /* Color palette */ 12603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG_Palette.StartIndex=ReadBlobLSBShort(image); 12613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG_Palette.NumOfEntries=ReadBlobLSBShort(image); 12623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors=WPG_Palette.NumOfEntries; 12643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) 12653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(ResourceLimitError, 12663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed"); 12673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=WPG_Palette.StartIndex; 12683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i < (int)WPG_Palette.NumOfEntries; i++) 12693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].red=ScaleCharToQuantum((char) 12713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 12723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].green=ScaleCharToQuantum((char) 12733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 12743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap[i].blue=ScaleCharToQuantum((char) 12753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ReadBlobByte(image)); 12763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ReadBlobByte(image); /*Opacity??*/ 12773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 127917f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy case 0x0E: 128017f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy Bitmap2Header1.Width=ReadBlobLSBShort(image); 128117f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy Bitmap2Header1.Height=ReadBlobLSBShort(image); 1282f8f295fde25dd8b1a50470d53b641d5265c0871fcristy if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Height == 0)) 1283f8f295fde25dd8b1a50470d53b641d5265c0871fcristy ThrowReaderException(CorruptImageError,"ImproperImageHeader"); 1284f8f295fde25dd8b1a50470d53b641d5265c0871fcristy Bitmap2Header1.Depth=ReadBlobByte(image); 12853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Bitmap2Header1.Compression=ReadBlobByte(image); 12863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(Bitmap2Header1.Compression > 1) 12883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; /*Unknown compression method */ 12893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Bitmap2Header1.Depth) 12903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 129269a0d3b5699c573f650e6b61f98ce4579d6f218cCristy bpp=1; 129369a0d3b5699c573f650e6b61f98ce4579d6f218cCristy break; 129469a0d3b5699c573f650e6b61f98ce4579d6f218cCristy case 2: 129569a0d3b5699c573f650e6b61f98ce4579d6f218cCristy bpp=2; 129669a0d3b5699c573f650e6b61f98ce4579d6f218cCristy break; 129769a0d3b5699c573f650e6b61f98ce4579d6f218cCristy case 3: 12989d314ff2c17a77996c05413c2013880387e50f0ecristy bpp=4; 12999d314ff2c17a77996c05413c2013880387e50f0ecristy break; 13009d314ff2c17a77996c05413c2013880387e50f0ecristy case 4: 13019d314ff2c17a77996c05413c2013880387e50f0ecristy bpp=8; 13023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 13043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bpp=24; 13053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 13073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; /*Ignore raster with unknown depth*/ 13083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->columns=Bitmap2Header1.Width; 13103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->rows=Bitmap2Header1.Height; 13113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=SetImageExtent(image,image->columns,image->rows,exception); 13122857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy if (status == MagickFalse) 13132857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy break; 13142857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy 13153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->colors == 0) && (bpp != 24)) 13163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t 1318f8f295fde25dd8b1a50470d53b641d5265c0871fcristy one; 1319f8f295fde25dd8b1a50470d53b641d5265c0871fcristy 13203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy one=1; 13213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors=one << bpp; 13223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (!AcquireImageColormap(image,image->colors,exception)) 13233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto NoMemory; 13243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 13263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(bpp < 24) 13283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if( image->colors<(one << bpp) && bpp!=24 ) 13293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap=(PixelInfo *) ResizeQuantumMemory( 13303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colormap,(size_t) (one << bpp), 1331f8f295fde25dd8b1a50470d53b641d5265c0871fcristy sizeof(*image->colormap)); 13323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 1333f8f295fde25dd8b1a50470d53b641d5265c0871fcristy 13343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch(Bitmap2Header1.Compression) 13365cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy { 1337efe601ce9ea5ad34ad0e8ad6e61d9be9b148b2a3cristy case 0: /*Uncompressed raster*/ 13385cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy { 13393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk=(ssize_t) ((bpp*image->columns+7)/8); 13403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) 13413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ldblk+1,sizeof(*BImgBuff)); 13423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (BImgBuff == (unsigned char *) NULL) 13433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto NoMemory; 1344f8f295fde25dd8b1a50470d53b641d5265c0871fcristy 1345f8f295fde25dd8b1a50470d53b641d5265c0871fcristy for(i=0; i< (ssize_t) image->rows; i++) 1346f8f295fde25dd8b1a50470d53b641d5265c0871fcristy { 13473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ReadBlob(image,ldblk,BImgBuff); 13483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy InsertRow(image,BImgBuff,i,bpp,exception); 13493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(BImgBuff) 13523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 13533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: /*RLE for WPG2 */ 13563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if( UnpackWPG2Raster(image,bpp,exception) < 0) 13583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto DecompressionFailed; 13593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if(CTM[0][0]<0 && !image_info->ping) 13643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { /*?? RotAngle=360-RotAngle;*/ 13653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 13663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *flop_image; 13673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flop_image = FlopImage(image, exception); 13693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (flop_image != (Image *) NULL) { 13703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(flop_image,image); 13713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 13723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,flop_image); 13733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Try to change CTM according to Flip - I am not sure, must be checked. 13753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,0)=-1; Tx(1,0)=0; Tx(2,0)=0; 13763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,1)= 0; Tx(1,1)=1; Tx(2,1)=0; 13773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,2)=(WPG._2Rect.X_ur+WPG._2Rect.X_ll); 13783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(1,2)=0; Tx(2,2)=1; */ 1379f8f295fde25dd8b1a50470d53b641d5265c0871fcristy } 1380f8f295fde25dd8b1a50470d53b641d5265c0871fcristy if(CTM[1][1]<0 && !image_info->ping) 1381e3b2bb83e885eb35642c7029cedab50c5e1b263dcristy { /*?? RotAngle=360-RotAngle;*/ 1382e3b2bb83e885eb35642c7029cedab50c5e1b263dcristy Image 1383e3b2bb83e885eb35642c7029cedab50c5e1b263dcristy *flip_image; 1384e3b2bb83e885eb35642c7029cedab50c5e1b263dcristy 1385e3b2bb83e885eb35642c7029cedab50c5e1b263dcristy flip_image = FlipImage(image, exception); 13863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (flip_image != (Image *) NULL) { 13873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DuplicateBlob(flip_image,image); 13883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemoveLastImageFromList(&image); 13893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AppendImageToList(&image,flip_image); 13903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* Try to change CTM according to Flip - I am not sure, must be checked. 13923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy float_matrix Tx(3,3); 13933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,0)= 1; Tx(1,0)= 0; Tx(2,0)=0; 13943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,1)= 0; Tx(1,1)=-1; Tx(2,1)=0; 13953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(0,2)= 0; Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll); 13963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Tx(2,2)=1; */ 13973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 139869a0d3b5699c573f650e6b61f98ce4579d6f218cCristy 13993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 140069a0d3b5699c573f650e6b61f98ce4579d6f218cCristy /* Allocate next image structure. */ 14013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AcquireNextImage(image_info,image,exception); 14023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->depth=8; 140369a0d3b5699c573f650e6b61f98ce4579d6f218cCristy if (image->next == (Image *) NULL) 14043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy goto Finish; 14053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=SyncNextImageInList(image); 1406f8f295fde25dd8b1a50470d53b641d5265c0871fcristy image->columns=image->rows=1; 14073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors=0; 14083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 14092245bab833d2ab8dc9a2ec3389f5e1bd72ca9ec3Cristy 14102245bab833d2ab8dc9a2ec3389f5e1bd72ca9ec3Cristy case 0x12: /* Postscript WPG2*/ 14112245bab833d2ab8dc9a2ec3389f5e1bd72ca9ec3Cristy i=ReadBlobLSBShort(image); 14122245bab833d2ab8dc9a2ec3389f5e1bd72ca9ec3Cristy if(Rec2.RecordLength > (unsigned int) i) 14132245bab833d2ab8dc9a2ec3389f5e1bd72ca9ec3Cristy image=ExtractPostscript(image,image_info, 14142245bab833d2ab8dc9a2ec3389f5e1bd72ca9ec3Cristy TellBlob(image)+i, /*skip PS header in the wpg2*/ 14153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ssize_t) (Rec2.RecordLength-i-2),exception); 14163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 14173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0x1B: /*bitmap rectangle*/ 14193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy WPG2Flags = LoadWPG2Flags(image,StartWPG.PosSizePrecision,NULL,&CTM); 14203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) WPG2Flags; 14213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 14223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 14263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 14283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CoderError,"DataEncodingSchemeIsNotSupported"); 14303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 143271709bfb884744dbf7c9030810cc8599600ab7d3cristy 14333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Finish: 14343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloseBlob(image); 14353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 14383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 14393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ssize_t 14413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scene=0; 14423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1443e7f5109f30fc7242d04a26174a9138483dda5b6acristy /* 14443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rewind list, removing any empty images while rewinding. 14453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 14463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=image; 14473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=NULL; 14483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (p != (Image *) NULL) 144955a804e2631f770f45d3a671076b0dfe29fdf188cristy { 14504f9709e37140157c7845a03f3612534081a5b540cristy Image *tmp=p; 145155a804e2631f770f45d3a671076b0dfe29fdf188cristy if ((p->rows == 0) || (p->columns == 0)) { 145255a804e2631f770f45d3a671076b0dfe29fdf188cristy p=p->previous; 1453a89189d6e227db53ecff8624fb6b4388560d9b4acristy DeleteImageFromList(&tmp); 145455a804e2631f770f45d3a671076b0dfe29fdf188cristy } else { 1455a89189d6e227db53ecff8624fb6b4388560d9b4acristy image=p; 1456a89189d6e227db53ecff8624fb6b4388560d9b4acristy p=p->previous; 145755a804e2631f770f45d3a671076b0dfe29fdf188cristy } 145855a804e2631f770f45d3a671076b0dfe29fdf188cristy } 1459d15e65928aec551b7388c2863de3e3e628e2e0ddcristy /* 146033204240c3ef57786ee59c2692ffe8ffdce97bf9cristy Fix scene numbers. 14613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 14623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (p=image; p != (Image *) NULL; p=p->next) 14633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->scene=(size_t) scene++; 14643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image == (Image *) NULL) 14663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowReaderException(CorruptImageError, 14673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "ImageFileDoesNotContainAnyImageData"); 14683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 14693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 14703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 14723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% R e g i s t e r W P G I m a g e % 14773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14809c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14819c282cc8767db9a3fafe507398b52fbdd0c03d9fCristy% 14823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Method RegisterWPGImage adds attributes for the WPG image format to 14833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the list of supported formats. The attributes include the image format 14843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% tag, a method to read and/or write the format, whether the format 14853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% supports the saving of more than one frame to the same file or blob, 14865cbc016effaa2d7ee617f46ca0a2371533d4ae17cristy% whether the format supports native in-memory I/O, and a brief 148717f11b056210f082a6d0e54ac5d68e6d72fa76b2cristy% description of the format. 1488a64d8007a138a0efeedc286de10538f2e8c7fe6bcristy% 14893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the RegisterWPGImage method is: 14903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% size_t RegisterWPGImage(void) 14923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 1493bd51246ae63047fa139606f6c6862ff989ab1fbdcristy*/ 1494bd51246ae63047fa139606f6c6862ff989ab1fbdcristyModuleExport size_t RegisterWPGImage(void) 14952857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy{ 1496d913ea1f524066a6a8bf3d046755a5c0f7eb471fcristy MagickInfo 14972857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy *entry; 14982857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy 1499bd51246ae63047fa139606f6c6862ff989ab1fbdcristy entry=AcquireMagickInfo("WPG","WPG","Word Perfect Graphics"); 15002857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy entry->decoder=(DecodeImageHandler *) ReadWPGImage; 15012857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy entry->magick=(IsImageFormatHandler *) IsWPG; 1502c9b129570a277337cf0e887229741497e2ead5cfcristy entry->flags|=CoderSeekableStreamFlag; 15032857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy (void) RegisterMagickInfo(entry); 1504f8f295fde25dd8b1a50470d53b641d5265c0871fcristy return(MagickImageCoderSignature); 150517f8c7215fff88fc1362e9d98f4ccdffb6a74950Cristy} 150687dc5e4e6f9471304ba85f508de30e664b484d3aCristy 15075eb36084e86f5ab4a877c2b31c19880b0b0b02e3Cristy/* 150869a0d3b5699c573f650e6b61f98ce4579d6f218cCristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 150969a0d3b5699c573f650e6b61f98ce4579d6f218cCristy% % 15102857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy% % 15112857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy% % 15122857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy% U n r e g i s t e r W P G I m a g e % 15132857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy% % 151491c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy% % 15152857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy% % 15162857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15172857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy% 151869a0d3b5699c573f650e6b61f98ce4579d6f218cCristy% Method UnregisterWPGImage removes format registrations made by the 15192857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy% WPG module from the list of supported formats. 152091c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy% 152191c2741e03e3e692f6fe04eb02d059edbc0edb90Cristy% The format of the UnregisterWPGImage method is: 1522f8f295fde25dd8b1a50470d53b641d5265c0871fcristy% 1523f8f295fde25dd8b1a50470d53b641d5265c0871fcristy% UnregisterWPGImage(void) 15242857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy% 1525f8f295fde25dd8b1a50470d53b641d5265c0871fcristy*/ 1526f8f295fde25dd8b1a50470d53b641d5265c0871fcristyModuleExport void UnregisterWPGImage(void) 15272857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy{ 1528f8f295fde25dd8b1a50470d53b641d5265c0871fcristy (void) UnregisterMagickInfo("WPG"); 15292857ffcd46fc4d091060c7e8aa9804f4b4d6efaacristy} 1530f8f295fde25dd8b1a50470d53b641d5265c0871fcristy