* Introduce a new method to ask the translator if it can handle the image
output size, if not it will not show up in the dynamically generated translator list. Folow up on ticket #4874. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35186 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -166,13 +166,6 @@ get_4_bits_per_pixel(uint8 *line, int32 x)
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
is_valid_size(int32 size)
|
||||
{
|
||||
return size == 16 || size == 32 || size == 48;
|
||||
}
|
||||
|
||||
|
||||
static uint8
|
||||
get_alpha_value(color_space space, uint32 value)
|
||||
{
|
||||
@@ -495,6 +488,13 @@ convert_bits_to_data(TranslatorBitmap &bitsHeader, uint8 *bitsData, ico_dir_entr
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
bool
|
||||
ICO::is_valid_size(int32 size)
|
||||
{
|
||||
return size == 16 || size == 32 || size == 48;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ICO::identify(BMessage *settings, BPositionIO &stream, uint8 &type, int32 &bitsPerPixel)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ struct rgba32_color {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
extern bool is_valid_size(int32 size);
|
||||
extern status_t identify(BMessage *settings, BPositionIO &stream, uint8 &type, int32 &bitsPerPixel);
|
||||
extern status_t convert_ico_to_bits(BMessage *settings, BPositionIO &source, BPositionIO &target);
|
||||
extern status_t convert_bits_to_ico(BMessage *settings, BPositionIO &source,
|
||||
|
||||
@@ -156,6 +156,15 @@ ICOTranslator::DerivedTranslate(BPositionIO *source,
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ICOTranslator::DerivedCanHandleImageSize(float width, float height) const
|
||||
{
|
||||
if (!ICO::is_valid_size(width) || !ICO::is_valid_size(height))
|
||||
return B_NO_TRANSLATOR;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
BView *
|
||||
ICOTranslator::NewConfigView(TranslatorSettings *settings)
|
||||
{
|
||||
|
||||
@@ -44,6 +44,9 @@ class ICOTranslator : public BaseTranslator {
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
uint32 outType, BPositionIO *outDestination, int32 baseType);
|
||||
|
||||
virtual status_t DerivedCanHandleImageSize(float width,
|
||||
float height) const;
|
||||
|
||||
virtual BView *NewConfigView(TranslatorSettings *settings);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -383,8 +383,7 @@ BaseTranslator::BitsCheck(BPositionIO *inSource, BMessage *ioExtension,
|
||||
memcpy(&sourceMagic, ch, sizeof(uint32));
|
||||
if (sourceMagic == kBitsMagic)
|
||||
return B_OK;
|
||||
else
|
||||
return B_OK + 1;
|
||||
return B_OK + 1;
|
||||
}
|
||||
|
||||
status_t
|
||||
@@ -392,17 +391,19 @@ BaseTranslator::BitsIdentify(BPositionIO *inSource,
|
||||
const translation_format *inFormat, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 outType)
|
||||
{
|
||||
status_t result;
|
||||
|
||||
result = BitsCheck(inSource, ioExtension, outType);
|
||||
if (result == B_OK)
|
||||
result = identify_bits_header(inSource, outInfo);
|
||||
else if (result == B_OK + 1)
|
||||
status_t result = BitsCheck(inSource, ioExtension, outType);
|
||||
if (result == B_OK) {
|
||||
TranslatorBitmap bitmap;
|
||||
result = identify_bits_header(inSource, outInfo, &bitmap);
|
||||
if (result == B_OK)
|
||||
result = DerivedCanHandleImageSize(bitmap.bounds.Width() + 1.0,
|
||||
bitmap.bounds.Height() + 1.0);
|
||||
} else if (result >= B_OK) {
|
||||
// if NOT B_TRANSLATOR_BITMAP, it could be an image in the
|
||||
// derived format
|
||||
result = DerivedIdentify(inSource, inFormat, ioExtension,
|
||||
outInfo, outType);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -452,7 +453,7 @@ BaseTranslator::Identify(BPositionIO *inSource,
|
||||
case B_TRANSLATOR_BITMAP:
|
||||
return BitsIdentify(inSource, inFormat, ioExtension,
|
||||
outInfo, outType);
|
||||
|
||||
|
||||
default:
|
||||
return DerivedIdentify(inSource, inFormat, ioExtension,
|
||||
outInfo, outType);
|
||||
@@ -595,7 +596,7 @@ BaseTranslator::Translate(BPositionIO *inSource,
|
||||
case B_TRANSLATOR_BITMAP:
|
||||
return BitsTranslate(inSource, inInfo, ioExtension, outType,
|
||||
outDestination);
|
||||
|
||||
|
||||
default:
|
||||
return DerivedTranslate(inSource, inInfo, ioExtension, outType,
|
||||
outDestination, -1);
|
||||
@@ -677,6 +678,13 @@ BaseTranslator::DerivedTranslate(BPositionIO *inSource,
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BaseTranslator::DerivedCanHandleImageSize(float width, float height) const
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
BView *
|
||||
BaseTranslator::NewConfigView(TranslatorSettings *settings)
|
||||
{
|
||||
|
||||
@@ -110,6 +110,8 @@ public:
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
uint32 outType, BPositionIO *outDestination, int32 baseType);
|
||||
|
||||
virtual status_t DerivedCanHandleImageSize(float width, float height) const;
|
||||
|
||||
virtual BView *NewConfigView(TranslatorSettings *settings);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user