Ticket #4874: translator.diff
File translator.diff, 4.8 KB (added by , 14 years ago) |
---|
-
src/add-ons/translators/ico/ICO.h
83 83 } 84 84 }; 85 85 86 86 extern bool is_valid_size(int32 size); 87 87 extern status_t identify(BMessage *settings, BPositionIO &stream, uint8 &type, int32 &bitsPerPixel); 88 88 extern status_t convert_ico_to_bits(BMessage *settings, BPositionIO &source, BPositionIO &target); 89 89 extern status_t convert_bits_to_ico(BMessage *settings, BPositionIO &source, -
src/add-ons/translators/ico/ICOTranslator.cpp
156 156 } 157 157 158 158 159 status_t 160 ICOTranslator::DerivedCanHandleImageSize(float width, float height) const 161 { 162 if (!ICO::is_valid_size(width) || !ICO::is_valid_size(height)) 163 return B_NO_TRANSLATOR; 164 return B_OK; 165 } 166 167 159 168 BView * 160 169 ICOTranslator::NewConfigView(TranslatorSettings *settings) 161 170 { -
src/add-ons/translators/ico/ICOTranslator.h
44 44 const translator_info *inInfo, BMessage *ioExtension, 45 45 uint32 outType, BPositionIO *outDestination, int32 baseType); 46 46 47 virtual status_t DerivedCanHandleImageSize(float width, 48 float height) const; 49 47 50 virtual BView *NewConfigView(TranslatorSettings *settings); 48 51 49 52 protected: -
src/add-ons/translators/ico/ICO.cpp
166 166 } 167 167 168 168 169 static bool170 is_valid_size(int32 size)171 {172 return size == 16 || size == 32 || size == 48;173 }174 175 176 169 static uint8 177 170 get_alpha_value(color_space space, uint32 value) 178 171 { … … 495 488 // #pragma mark - 496 489 497 490 491 bool 492 ICO::is_valid_size(int32 size) 493 { 494 return size == 16 || size == 32 || size == 48; 495 } 496 497 498 498 status_t 499 499 ICO::identify(BMessage *settings, BPositionIO &stream, uint8 &type, int32 &bitsPerPixel) 500 500 { -
src/add-ons/translators/shared/BaseTranslator.cpp
383 383 memcpy(&sourceMagic, ch, sizeof(uint32)); 384 384 if (sourceMagic == kBitsMagic) 385 385 return B_OK; 386 else 387 return B_OK + 1; 386 return B_OK + 1; 388 387 } 389 388 390 389 status_t … … 392 391 const translation_format *inFormat, BMessage *ioExtension, 393 392 translator_info *outInfo, uint32 outType) 394 393 { 395 status_t result; 396 397 result = BitsCheck(inSource, ioExtension, outType); 398 if (result == B_OK) 399 result = identify_bits_header(inSource, outInfo); 400 else if (result == B_OK + 1) 394 status_t result = BitsCheck(inSource, ioExtension, outType); 395 if (result == B_OK) { 396 TranslatorBitmap bitmap; 397 result = identify_bits_header(inSource, outInfo, &bitmap); 398 if (result == B_OK) 399 result = DerivedCanHandleImageSize(bitmap.bounds.Width() + 1.0, 400 bitmap.bounds.Height() + 1.0); 401 } else if (result >= B_OK) { 401 402 // if NOT B_TRANSLATOR_BITMAP, it could be an image in the 402 403 // derived format 403 404 result = DerivedIdentify(inSource, inFormat, ioExtension, 404 405 outInfo, outType); 405 406 } 406 407 return result; 407 408 } 408 409 … … 452 453 case B_TRANSLATOR_BITMAP: 453 454 return BitsIdentify(inSource, inFormat, ioExtension, 454 455 outInfo, outType); 455 456 456 457 default: 457 458 return DerivedIdentify(inSource, inFormat, ioExtension, 458 459 outInfo, outType); … … 595 596 case B_TRANSLATOR_BITMAP: 596 597 return BitsTranslate(inSource, inInfo, ioExtension, outType, 597 598 outDestination); 598 599 599 600 default: 600 601 return DerivedTranslate(inSource, inInfo, ioExtension, outType, 601 602 outDestination, -1); … … 677 678 } 678 679 679 680 681 status_t 682 BaseTranslator::DerivedCanHandleImageSize(float width, float height) const 683 { 684 return B_OK; 685 } 686 687 680 688 BView * 681 689 BaseTranslator::NewConfigView(TranslatorSettings *settings) 682 690 { -
src/add-ons/translators/shared/BaseTranslator.h
110 110 const translator_info *inInfo, BMessage *ioExtension, 111 111 uint32 outType, BPositionIO *outDestination, int32 baseType); 112 112 113 virtual status_t DerivedCanHandleImageSize(float width, float height) const; 114 113 115 virtual BView *NewConfigView(TranslatorSettings *settings); 114 116 115 117