initial check-in for TIFFTranslator (doesn't do anything yet)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2887 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e6cc97f061
commit
129a87e630
5
src/add-ons/translators/tifftranslator/Jamfile
Executable file
5
src/add-ons/translators/tifftranslator/Jamfile
Executable file
@ -0,0 +1,5 @@
|
||||
SubDir OBOS_TOP src add-ons translators tifftranslator ;
|
||||
|
||||
Translator TIFFTranslator : TIFFMain.cpp TIFFTranslator.cpp TIFFView.cpp TIFFWindow.cpp ;
|
||||
|
||||
LinkSharedOSLibs TIFFTranslator : be translation ;
|
103
src/add-ons/translators/tifftranslator/TIFFMain.cpp
Executable file
103
src/add-ons/translators/tifftranslator/TIFFMain.cpp
Executable file
@ -0,0 +1,103 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFTranslator
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// Version:
|
||||
//
|
||||
// This translator opens and writes TIFF images.
|
||||
//
|
||||
//
|
||||
// This application and all source files used in its construction, except
|
||||
// where noted, are licensed under the MIT License, and have been written
|
||||
// and are:
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <Application.h>
|
||||
#include <Screen.h>
|
||||
#include <Alert.h>
|
||||
#include "TIFFTranslator.h"
|
||||
#include "TIFFWindow.h"
|
||||
#include "TIFFView.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// main
|
||||
//
|
||||
// Creates a BWindow for displaying info about the TIFFTranslator
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
int
|
||||
main()
|
||||
{
|
||||
BApplication app("application/x-vnd.obos-tiff-translator");
|
||||
TIFFTranslator *ptranslator = new TIFFTranslator;
|
||||
BView *view = NULL;
|
||||
BRect rect(0, 0, 225, 175);
|
||||
if (ptranslator->MakeConfigurationView(NULL, &view, &rect)) {
|
||||
BAlert *err = new BAlert("Error",
|
||||
"Unable to create the TIFFTranslator view.", "OK");
|
||||
err->Go();
|
||||
return 1;
|
||||
}
|
||||
// release the translator even though I never really used it anyway
|
||||
ptranslator->Release();
|
||||
ptranslator = NULL;
|
||||
|
||||
TIFFWindow *wnd = new TIFFWindow(rect);
|
||||
view->ResizeTo(rect.Width(), rect.Height());
|
||||
wnd->AddChild(view);
|
||||
BPoint wndpt = B_ORIGIN;
|
||||
{
|
||||
BScreen scrn;
|
||||
BRect frame = scrn.Frame();
|
||||
frame.InsetBy(10, 23);
|
||||
// if the point is outside of the screen frame,
|
||||
// use the mouse location to find a better point
|
||||
if (!frame.Contains(wndpt)) {
|
||||
uint32 dummy;
|
||||
view->GetMouse(&wndpt, &dummy, false);
|
||||
wndpt.x -= rect.Width() / 2;
|
||||
wndpt.y -= rect.Height() / 2;
|
||||
// clamp location to screen
|
||||
if (wndpt.x < frame.left)
|
||||
wndpt.x = frame.left;
|
||||
if (wndpt.y < frame.top)
|
||||
wndpt.y = frame.top;
|
||||
if (wndpt.x > frame.right)
|
||||
wndpt.x = frame.right;
|
||||
if (wndpt.y > frame.bottom)
|
||||
wndpt.y = frame.bottom;
|
||||
}
|
||||
}
|
||||
wnd->MoveTo(wndpt);
|
||||
wnd->Show();
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
393
src/add-ons/translators/tifftranslator/TIFFTranslator.cpp
Executable file
393
src/add-ons/translators/tifftranslator/TIFFTranslator.cpp
Executable file
@ -0,0 +1,393 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFTranslator
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFTranslator.cpp
|
||||
//
|
||||
// This BTranslator based object is for opening and writing
|
||||
// TIFF images.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "TIFFTranslator.h"
|
||||
#include "TIFFView.h"
|
||||
|
||||
// The input formats that this translator supports.
|
||||
translation_format gInputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_BITMAP,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
BBT_IN_QUALITY,
|
||||
BBT_IN_CAPABILITY,
|
||||
"image/x-be-bitmap",
|
||||
"Be Bitmap Format (TIFFTranslator)"
|
||||
},
|
||||
{
|
||||
B_TIFF_FORMAT,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
TIFF_IN_QUALITY,
|
||||
TIFF_IN_CAPABILITY,
|
||||
"image/tiff",
|
||||
"TIFF Image"
|
||||
}
|
||||
};
|
||||
|
||||
// The output formats that this translator supports.
|
||||
translation_format gOutputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_BITMAP,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
BBT_OUT_QUALITY,
|
||||
BBT_OUT_CAPABILITY,
|
||||
"image/x-be-bitmap",
|
||||
"Be Bitmap Format (TIFFTranslator)"
|
||||
},
|
||||
{
|
||||
B_TIFF_FORMAT,
|
||||
B_TRANSLATOR_BITMAP,
|
||||
TIFF_OUT_QUALITY,
|
||||
TIFF_OUT_CAPABILITY,
|
||||
"image/tiff",
|
||||
"TIFF Image"
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// make_nth_translator
|
||||
//
|
||||
// Creates a TIFFTranslator object to be used by BTranslatorRoster
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: n, The translator to return. Since
|
||||
// TIFFTranslator only publishes one
|
||||
// translator, it only returns a
|
||||
// TIFFTranslator if n == 0
|
||||
//
|
||||
// you, The image_id of the add-on that
|
||||
// contains code (not used).
|
||||
//
|
||||
// flags, Has no meaning yet, should be 0.
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: NULL if n is not zero,
|
||||
// a new TIFFTranslator if n is zero
|
||||
// ---------------------------------------------------------------
|
||||
BTranslator *
|
||||
make_nth_translator(int32 n, image_id you, uint32 flags, ...)
|
||||
{
|
||||
if (!n)
|
||||
return new TIFFTranslator();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Sets up the version info and the name of the translator so that
|
||||
// these values can be returned when they are requested.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFTranslator::TIFFTranslator()
|
||||
: BTranslator()
|
||||
{
|
||||
strcpy(fName, "TIFF Images");
|
||||
sprintf(fInfo, "TIFF image translator v%d.%d.%d %s",
|
||||
TIFF_TRANSLATOR_VERSION / 100, (TIFF_TRANSLATOR_VERSION / 10) % 10,
|
||||
TIFF_TRANSLATOR_VERSION % 10, __DATE__);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Does nothing
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFTranslator::~TIFFTranslator()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// TranslatorName
|
||||
//
|
||||
// Returns the short name of the translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: a const char * to the short name of the translator
|
||||
// ---------------------------------------------------------------
|
||||
const char *
|
||||
TIFFTranslator::TranslatorName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// TranslatorInfo
|
||||
//
|
||||
// Returns a more verbose name for the translator than the one
|
||||
// TranslatorName() returns. This usually includes version info.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: a const char * to the verbose name of the translator
|
||||
// ---------------------------------------------------------------
|
||||
const char *
|
||||
TIFFTranslator::TranslatorInfo() const
|
||||
{
|
||||
return fInfo;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// TranslatorVersion
|
||||
//
|
||||
// Returns the integer representation of the current version of
|
||||
// this translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
int32
|
||||
TIFFTranslator::TranslatorVersion() const
|
||||
{
|
||||
return TIFF_TRANSLATOR_VERSION;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// InputFormats
|
||||
//
|
||||
// Returns a list of input formats supported by this translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: out_count, The number of input formats
|
||||
// support is returned here.
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: the list of input formats and the number of input
|
||||
// formats through the out_count parameter, if out_count is NULL,
|
||||
// NULL is returned
|
||||
// ---------------------------------------------------------------
|
||||
const translation_format *
|
||||
TIFFTranslator::InputFormats(int32 *out_count) const
|
||||
{
|
||||
if (out_count) {
|
||||
*out_count = sizeof(gInputFormats) /
|
||||
sizeof(translation_format);
|
||||
return gInputFormats;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// OutputFormats
|
||||
//
|
||||
// Returns a list of output formats supported by this translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: out_count, The number of output formats
|
||||
// support is returned here.
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: the list of output formats and the number of output
|
||||
// formats through the out_count parameter, if out_count is NULL,
|
||||
// NULL is returned
|
||||
// ---------------------------------------------------------------
|
||||
const translation_format *
|
||||
TIFFTranslator::OutputFormats(int32 *out_count) const
|
||||
{
|
||||
if (out_count) {
|
||||
*out_count = sizeof(gOutputFormats) /
|
||||
sizeof(translation_format);
|
||||
return gOutputFormats;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Identify
|
||||
//
|
||||
// Examines the data from inSource and determines if it is in a
|
||||
// format that this translator knows how to work with.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: inSource, where the data to examine is
|
||||
//
|
||||
// inFormat, a hint about the data in inSource,
|
||||
// it is ignored since it is only a hint
|
||||
//
|
||||
// ioExtension, configuration settings for the
|
||||
// translator (not used)
|
||||
//
|
||||
// outInfo, information about what data is in
|
||||
// inSource and how well this translator
|
||||
// can handle that data is stored here
|
||||
//
|
||||
// outType, The format that the user wants
|
||||
// the data in inSource to be
|
||||
// converted to
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: B_NO_TRANSLATOR, if this translator can't handle
|
||||
// the data in inSource
|
||||
//
|
||||
// B_ERROR, if there was an error converting the data to the host
|
||||
// format
|
||||
//
|
||||
// B_BAD_VALUE, if the settings in ioExtension are bad
|
||||
//
|
||||
// B_OK, if this translator understood the data and there were
|
||||
// no errors found
|
||||
//
|
||||
// Other errors if BPositionIO::Read() returned an error value
|
||||
// ---------------------------------------------------------------
|
||||
status_t
|
||||
TIFFTranslator::Identify(BPositionIO *inSource,
|
||||
const translation_format *inFormat, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 outType)
|
||||
{
|
||||
if (!outType)
|
||||
outType = B_TRANSLATOR_BITMAP;
|
||||
if (outType != B_TRANSLATOR_BITMAP && outType != B_TIFF_FORMAT)
|
||||
return B_NO_TRANSLATOR;
|
||||
|
||||
return B_NO_TRANSLATOR;
|
||||
// translator isn't implemented yet
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Translate
|
||||
//
|
||||
// Translates the data in inSource to the type outType and stores
|
||||
// the translated data in outDestination.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: inSource, the data to be translated
|
||||
//
|
||||
// inInfo, hint about the data in inSource (not used)
|
||||
//
|
||||
// ioExtension, configuration options for the
|
||||
// translator
|
||||
//
|
||||
// outType, the type to convert inSource to
|
||||
//
|
||||
// outDestination, where the translated data is
|
||||
// put
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: B_BAD_VALUE, if the options in ioExtension are bad
|
||||
//
|
||||
// B_NO_TRANSLATOR, if this translator doesn't understand the data
|
||||
//
|
||||
// B_ERROR, if there was an error allocating memory or converting
|
||||
// data
|
||||
//
|
||||
// B_OK, if all went well
|
||||
// ---------------------------------------------------------------
|
||||
status_t
|
||||
TIFFTranslator::Translate(BPositionIO *inSource,
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
uint32 outType, BPositionIO *outDestination)
|
||||
{
|
||||
if (!outType)
|
||||
outType = B_TRANSLATOR_BITMAP;
|
||||
if (outType != B_TRANSLATOR_BITMAP && outType != B_TIFF_FORMAT)
|
||||
return B_NO_TRANSLATOR;
|
||||
|
||||
return B_NO_TRANSLATOR;
|
||||
// translator isn't implemented yet
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// MakeConfigurationView
|
||||
//
|
||||
// Makes a BView object for configuring / displaying info about
|
||||
// this translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: ioExtension, configuration options for the
|
||||
// translator
|
||||
//
|
||||
// outView, the view to configure the
|
||||
// translator is stored here
|
||||
//
|
||||
// outExtent, the bounds of the view are
|
||||
// stored here
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
status_t
|
||||
TIFFTranslator::MakeConfigurationView(BMessage *ioExtension, BView **outView,
|
||||
BRect *outExtent)
|
||||
{
|
||||
if (!outView || !outExtent)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
TIFFView *view = new TIFFView(BRect(0, 0, 225, 175),
|
||||
"TIFFTranslator Settings", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
*outView = view;
|
||||
*outExtent = view->Bounds();
|
||||
|
||||
return B_OK;
|
||||
}
|
109
src/add-ons/translators/tifftranslator/TIFFTranslator.h
Executable file
109
src/add-ons/translators/tifftranslator/TIFFTranslator.h
Executable file
@ -0,0 +1,109 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFTranslator
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFTranslator.h
|
||||
//
|
||||
// This BTranslator based object is for opening and writing
|
||||
// TIFF images.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFF_TRANSLATOR_H
|
||||
#define TIFF_TRANSLATOR_H
|
||||
|
||||
#include <Translator.h>
|
||||
#include <TranslatorFormats.h>
|
||||
#include <TranslationDefs.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <DataIO.h>
|
||||
#include <File.h>
|
||||
#include <ByteOrder.h>
|
||||
#include <fs_attr.h>
|
||||
|
||||
#define TIFF_TRANSLATOR_VERSION 100
|
||||
|
||||
#define TIFF_IN_QUALITY 0.1
|
||||
#define TIFF_IN_CAPABILITY 0.1
|
||||
#define TIFF_OUT_QUALITY 0.0
|
||||
#define TIFF_OUT_CAPABILITY 0.0
|
||||
|
||||
#define BBT_IN_QUALITY 0.4
|
||||
#define BBT_IN_CAPABILITY 0.6
|
||||
#define BBT_OUT_QUALITY 0.4
|
||||
#define BBT_OUT_CAPABILITY 0.6
|
||||
|
||||
class TIFFTranslator : public BTranslator {
|
||||
public:
|
||||
TIFFTranslator();
|
||||
|
||||
virtual const char *TranslatorName() const;
|
||||
// returns the short name of the translator
|
||||
|
||||
virtual const char *TranslatorInfo() const;
|
||||
// returns a verbose name/description for the translator
|
||||
|
||||
virtual int32 TranslatorVersion() const;
|
||||
// returns the version of the translator
|
||||
|
||||
virtual const translation_format *InputFormats(int32 *out_count)
|
||||
const;
|
||||
// returns the input formats and the count of input formats
|
||||
// that this translator supports
|
||||
|
||||
virtual const translation_format *OutputFormats(int32 *out_count)
|
||||
const;
|
||||
// returns the output formats and the count of output formats
|
||||
// that this translator supports
|
||||
|
||||
virtual status_t Identify(BPositionIO *inSource,
|
||||
const translation_format *inFormat, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 outType);
|
||||
// determines whether or not this translator can convert the
|
||||
// data in inSource to the type outType
|
||||
|
||||
virtual status_t Translate(BPositionIO *inSource,
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
uint32 outType, BPositionIO *outDestination);
|
||||
// this function is the whole point of the Translation Kit,
|
||||
// it translates the data in inSource to outDestination
|
||||
// using the format outType
|
||||
|
||||
virtual status_t MakeConfigurationView(BMessage *ioExtension,
|
||||
BView **outView, BRect *outExtent);
|
||||
// creates and returns the view for displaying information
|
||||
// about this translator
|
||||
|
||||
protected:
|
||||
virtual ~TIFFTranslator();
|
||||
// this is protected because the object is deleted by the
|
||||
// Release() function instead of being deleted directly by
|
||||
// the user
|
||||
|
||||
private:
|
||||
char fName[30];
|
||||
char fInfo[100];
|
||||
};
|
||||
|
||||
#endif // #ifndef TIFF_TRANSLATOR_H
|
115
src/add-ons/translators/tifftranslator/TIFFView.cpp
Executable file
115
src/add-ons/translators/tifftranslator/TIFFView.cpp
Executable file
@ -0,0 +1,115 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFView
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFView.cpp
|
||||
//
|
||||
// This BView based object displays information about the TIFFTranslator.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "TIFFView.h"
|
||||
#include "TIFFTranslator.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Sets up the view settings
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFView::TIFFView(const BRect &frame, const char *name,
|
||||
uint32 resize, uint32 flags)
|
||||
: BView(frame, name, resize, flags)
|
||||
{
|
||||
SetViewColor(220,220,220,0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Does nothing
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFView::~TIFFView()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Draw
|
||||
//
|
||||
// Draws information about the TIFFTranslator to this view.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: area, not used
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
void
|
||||
TIFFView::Draw(BRect area)
|
||||
{
|
||||
SetFont(be_bold_font);
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
float xbold, ybold;
|
||||
xbold = fh.descent + 1;
|
||||
ybold = fh.ascent + fh.descent * 2 + fh.leading;
|
||||
|
||||
char title[] = "OpenBeOS TIFF Image Translator";
|
||||
DrawString(title, BPoint(xbold, ybold));
|
||||
|
||||
SetFont(be_plain_font);
|
||||
font_height plainh;
|
||||
GetFontHeight(&plainh);
|
||||
float yplain;
|
||||
yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;
|
||||
|
||||
char detail[100];
|
||||
sprintf(detail, "Version %d.%d.%d %s",
|
||||
TIFF_TRANSLATOR_VERSION / 100, (TIFF_TRANSLATOR_VERSION / 10) % 10,
|
||||
TIFF_TRANSLATOR_VERSION % 10, __DATE__);
|
||||
DrawString(detail, BPoint(xbold, yplain + ybold));
|
||||
/* char copyright[] = "© 2003 OpenBeOS Project";
|
||||
DrawString(copyright, BPoint(xbold, yplain * 2 + ybold));
|
||||
*/
|
||||
char writtenby[] = "Written by the OBOS Translation Kit Team";
|
||||
DrawString(writtenby, BPoint(xbold, yplain * 7 + ybold));
|
||||
}
|
51
src/add-ons/translators/tifftranslator/TIFFView.h
Executable file
51
src/add-ons/translators/tifftranslator/TIFFView.h
Executable file
@ -0,0 +1,51 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFView
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFView.h
|
||||
//
|
||||
// This BView based object displays information about the TIFFTranslator.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFFVIEW_H
|
||||
#define TIFFVIEW_H
|
||||
|
||||
#include <View.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
|
||||
class TIFFView : public BView {
|
||||
public:
|
||||
TIFFView(const BRect &frame, const char *name, uint32 resize,
|
||||
uint32 flags);
|
||||
// sets up the view
|
||||
|
||||
~TIFFView();
|
||||
// does nothing
|
||||
|
||||
virtual void Draw(BRect area);
|
||||
// draws information about the TIFFTranslator
|
||||
};
|
||||
|
||||
#endif // #ifndef TIFFVIEW_H
|
69
src/add-ons/translators/tifftranslator/TIFFWindow.cpp
Executable file
69
src/add-ons/translators/tifftranslator/TIFFWindow.cpp
Executable file
@ -0,0 +1,69 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFWindow
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFWindow.cpp
|
||||
//
|
||||
// This BWindow based object is used to hold the TIFFView object when the
|
||||
// user runs the TIFFTranslator as an application.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "TIFFWindow.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Sets up the BWindow for holding a TIFFView
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: area, The bounds of the window
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFWindow::TIFFWindow(BRect area)
|
||||
: BWindow(area, "TIFFTranslator", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Posts a quit message so that the application is close properly
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
TIFFWindow::~TIFFWindow()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
48
src/add-ons/translators/tifftranslator/TIFFWindow.h
Executable file
48
src/add-ons/translators/tifftranslator/TIFFWindow.h
Executable file
@ -0,0 +1,48 @@
|
||||
/*****************************************************************************/
|
||||
// TIFFWindow
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// TIFFWindow.h
|
||||
//
|
||||
// This BWindow based object is used to hold the TIFFView object when the
|
||||
// user runs the TIFFTranslator as an application.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef TIFFWINDOW_H
|
||||
#define TIFFWINDOW_H
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
class TIFFWindow : public BWindow {
|
||||
public:
|
||||
TIFFWindow(BRect area);
|
||||
// Sets up a BWindow with bounds area
|
||||
|
||||
~TIFFWindow();
|
||||
// Posts a quit message so that the application closes properly
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user