added some comments
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@521 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,4 +1,35 @@
|
|||||||
// BMPMain.cpp
|
/*****************************************************************************/
|
||||||
|
// BMPTranslator
|
||||||
|
//
|
||||||
|
// Version: 1.0.0 Beta
|
||||||
|
//
|
||||||
|
// This translator opens and writes BMP files.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// 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) 2002 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 <Application.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
@@ -7,7 +38,21 @@
|
|||||||
#include "BMPWindow.h"
|
#include "BMPWindow.h"
|
||||||
#include "BMPView.h"
|
#include "BMPView.h"
|
||||||
|
|
||||||
int main()
|
// ---------------------------------------------------------------
|
||||||
|
// main
|
||||||
|
//
|
||||||
|
// Creates a BWindow for displaying info about the BMPTranslator
|
||||||
|
//
|
||||||
|
// Preconditions:
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
//
|
||||||
|
// Postconditions:
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
BApplication app("application/x-vnd.obos-bmp-translator");
|
BApplication app("application/x-vnd.obos-bmp-translator");
|
||||||
BMPTranslator *ptranslator = new BMPTranslator;
|
BMPTranslator *ptranslator = new BMPTranslator;
|
||||||
|
|||||||
@@ -1,4 +1,30 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
// BMPTranslator
|
||||||
// BMPTranslator.h
|
// BMPTranslator.h
|
||||||
|
//
|
||||||
|
// This BTranslator based object is for opening and writing BMP files.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 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 BMP_TRANSLATOR_H
|
#ifndef BMP_TRANSLATOR_H
|
||||||
#define BMP_TRANSLATOR_H
|
#define BMP_TRANSLATOR_H
|
||||||
@@ -45,7 +71,7 @@ struct MSInfoHeader {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct OS2InfoHeader {
|
struct OS2InfoHeader {
|
||||||
uint32 size; // size of this struct (40)
|
uint32 size; // size of this struct (12)
|
||||||
uint16 width; // bitmap width
|
uint16 width; // bitmap width
|
||||||
uint16 height; // bitmap height
|
uint16 height; // bitmap height
|
||||||
uint16 planes; // number of planes, always 1?
|
uint16 planes; // number of planes, always 1?
|
||||||
|
|||||||
@@ -1,21 +1,88 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
// BMPView
|
||||||
// BMPView.cpp
|
// BMPView.cpp
|
||||||
|
//
|
||||||
|
// This BView based object displays information about the BMPTranslator.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 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 <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "BMPView.h"
|
#include "BMPView.h"
|
||||||
#include "BMPTranslator.h"
|
#include "BMPTranslator.h"
|
||||||
|
|
||||||
BMPView::BMPView(const BRect &frame, const char *name, uint32 resize, uint32 flags) :
|
// ---------------------------------------------------------------
|
||||||
BView(frame, name, resize, flags)
|
// Constructor
|
||||||
|
//
|
||||||
|
// Sets up the view settings
|
||||||
|
//
|
||||||
|
// Preconditions:
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
//
|
||||||
|
// Postconditions:
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
BMPView::BMPView(const BRect &frame, const char *name,
|
||||||
|
uint32 resize, uint32 flags)
|
||||||
|
: BView(frame, name, resize, flags)
|
||||||
{
|
{
|
||||||
SetViewColor(220,220,220,0);
|
SetViewColor(220,220,220,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
// Destructor
|
||||||
|
//
|
||||||
|
// Does nothing
|
||||||
|
//
|
||||||
|
// Preconditions:
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
//
|
||||||
|
// Postconditions:
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// ---------------------------------------------------------------
|
||||||
BMPView::~BMPView()
|
BMPView::~BMPView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BMPView::Draw(BRect area)
|
// ---------------------------------------------------------------
|
||||||
|
// Draw
|
||||||
|
//
|
||||||
|
// Draws information about the BMPTranslator to this view.
|
||||||
|
//
|
||||||
|
// Preconditions:
|
||||||
|
//
|
||||||
|
// Parameters: area, not used
|
||||||
|
//
|
||||||
|
// Postconditions:
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
void
|
||||||
|
BMPView::Draw(BRect area)
|
||||||
{
|
{
|
||||||
SetFont(be_bold_font);
|
SetFont(be_bold_font);
|
||||||
font_height fh;
|
font_height fh;
|
||||||
|
|||||||
@@ -1,4 +1,30 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
// BMPView
|
||||||
// BMPView.h
|
// BMPView.h
|
||||||
|
//
|
||||||
|
// This BView based object displays information about the BMPTranslator.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 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 BMPVIEW_H
|
#ifndef BMPVIEW_H
|
||||||
#define BMPVIEW_H
|
#define BMPVIEW_H
|
||||||
@@ -7,13 +33,17 @@
|
|||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
|
|
||||||
class BMPView : public BView
|
class BMPView : public BView {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BMPView(const BRect &frame, const char *name, uint32 resize, uint32 flags);
|
BMPView(const BRect &frame, const char *name, uint32 resize,
|
||||||
|
uint32 flags);
|
||||||
|
// sets up the view
|
||||||
|
|
||||||
~BMPView();
|
~BMPView();
|
||||||
|
// does nothing
|
||||||
|
|
||||||
virtual void Draw(BRect area);
|
virtual void Draw(BRect area);
|
||||||
|
// draws information about the BMPTranslator
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifndef BMPVIEW_H
|
#endif // #ifndef BMPVIEW_H
|
||||||
|
|||||||
@@ -1,12 +1,66 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
// BMPWindow
|
||||||
// BMPWindow.cpp
|
// BMPWindow.cpp
|
||||||
|
//
|
||||||
|
// This BWindow based object is used to hold the BMPView object when the
|
||||||
|
// user runs the BMPTranslator as an application.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 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 "BMPWindow.h"
|
#include "BMPWindow.h"
|
||||||
|
|
||||||
BMPWindow::BMPWindow(BRect area) :
|
// ---------------------------------------------------------------
|
||||||
BWindow(area, "BMPTranslator", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
// Constructor
|
||||||
|
//
|
||||||
|
// Sets up the BWindow for holding a BMPView
|
||||||
|
//
|
||||||
|
// Preconditions:
|
||||||
|
//
|
||||||
|
// Parameters: area, The bounds of the window
|
||||||
|
//
|
||||||
|
// Postconditions:
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
BMPWindow::BMPWindow(BRect area)
|
||||||
|
: BWindow(area, "BMPTranslator", 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:
|
||||||
|
// ---------------------------------------------------------------
|
||||||
BMPWindow::~BMPWindow()
|
BMPWindow::~BMPWindow()
|
||||||
{
|
{
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
|||||||
@@ -1,4 +1,31 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
// BMPWindow
|
||||||
// BMPWindow.h
|
// BMPWindow.h
|
||||||
|
//
|
||||||
|
// This BWindow based object is used to hold the BMPView object when the
|
||||||
|
// user runs the BMPTranslator as an application.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 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 BMPWINDOW_H
|
#ifndef BMPWINDOW_H
|
||||||
#define BMPWINDOW_H
|
#define BMPWINDOW_H
|
||||||
@@ -10,7 +37,10 @@
|
|||||||
class BMPWindow : public BWindow {
|
class BMPWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
BMPWindow(BRect area);
|
BMPWindow(BRect area);
|
||||||
|
// Sets up a BWindow with bounds area
|
||||||
|
|
||||||
~BMPWindow();
|
~BMPWindow();
|
||||||
|
// Posts a quit message so that the application closes properly
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user