* 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
|
static uint8
|
||||||
get_alpha_value(color_space space, uint32 value)
|
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 -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ICO::is_valid_size(int32 size)
|
||||||
|
{
|
||||||
|
return size == 16 || size == 32 || size == 48;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ICO::identify(BMessage *settings, BPositionIO &stream, uint8 &type, int32 &bitsPerPixel)
|
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 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_ico_to_bits(BMessage *settings, BPositionIO &source, BPositionIO &target);
|
||||||
extern status_t convert_bits_to_ico(BMessage *settings, BPositionIO &source,
|
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 *
|
BView *
|
||||||
ICOTranslator::NewConfigView(TranslatorSettings *settings)
|
ICOTranslator::NewConfigView(TranslatorSettings *settings)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ class ICOTranslator : public BaseTranslator {
|
|||||||
const translator_info *inInfo, BMessage *ioExtension,
|
const translator_info *inInfo, BMessage *ioExtension,
|
||||||
uint32 outType, BPositionIO *outDestination, int32 baseType);
|
uint32 outType, BPositionIO *outDestination, int32 baseType);
|
||||||
|
|
||||||
|
virtual status_t DerivedCanHandleImageSize(float width,
|
||||||
|
float height) const;
|
||||||
|
|
||||||
virtual BView *NewConfigView(TranslatorSettings *settings);
|
virtual BView *NewConfigView(TranslatorSettings *settings);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -383,8 +383,7 @@ BaseTranslator::BitsCheck(BPositionIO *inSource, BMessage *ioExtension,
|
|||||||
memcpy(&sourceMagic, ch, sizeof(uint32));
|
memcpy(&sourceMagic, ch, sizeof(uint32));
|
||||||
if (sourceMagic == kBitsMagic)
|
if (sourceMagic == kBitsMagic)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
else
|
return B_OK + 1;
|
||||||
return B_OK + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
@@ -392,17 +391,19 @@ BaseTranslator::BitsIdentify(BPositionIO *inSource,
|
|||||||
const translation_format *inFormat, BMessage *ioExtension,
|
const translation_format *inFormat, BMessage *ioExtension,
|
||||||
translator_info *outInfo, uint32 outType)
|
translator_info *outInfo, uint32 outType)
|
||||||
{
|
{
|
||||||
status_t result;
|
status_t result = BitsCheck(inSource, ioExtension, outType);
|
||||||
|
if (result == B_OK) {
|
||||||
result = BitsCheck(inSource, ioExtension, outType);
|
TranslatorBitmap bitmap;
|
||||||
if (result == B_OK)
|
result = identify_bits_header(inSource, outInfo, &bitmap);
|
||||||
result = identify_bits_header(inSource, outInfo);
|
if (result == B_OK)
|
||||||
else if (result == B_OK + 1)
|
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
|
// if NOT B_TRANSLATOR_BITMAP, it could be an image in the
|
||||||
// derived format
|
// derived format
|
||||||
result = DerivedIdentify(inSource, inFormat, ioExtension,
|
result = DerivedIdentify(inSource, inFormat, ioExtension,
|
||||||
outInfo, outType);
|
outInfo, outType);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,6 +678,13 @@ BaseTranslator::DerivedTranslate(BPositionIO *inSource,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BaseTranslator::DerivedCanHandleImageSize(float width, float height) const
|
||||||
|
{
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BView *
|
BView *
|
||||||
BaseTranslator::NewConfigView(TranslatorSettings *settings)
|
BaseTranslator::NewConfigView(TranslatorSettings *settings)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ public:
|
|||||||
const translator_info *inInfo, BMessage *ioExtension,
|
const translator_info *inInfo, BMessage *ioExtension,
|
||||||
uint32 outType, BPositionIO *outDestination, int32 baseType);
|
uint32 outType, BPositionIO *outDestination, int32 baseType);
|
||||||
|
|
||||||
|
virtual status_t DerivedCanHandleImageSize(float width, float height) const;
|
||||||
|
|
||||||
virtual BView *NewConfigView(TranslatorSettings *settings);
|
virtual BView *NewConfigView(TranslatorSettings *settings);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user