[Scummvm-cvs-logs] CVS: scummex image.cpp,1.22,1.23 resource.cpp,1.26,1.27 wxwindows.cpp,1.34,1.35 wxwindows.h,1.16,1.17
Adrien Mercier
yoshizf at users.sourceforge.net
Wed Oct 1 03:07:04 CEST 2003
Update of /cvsroot/scummvm/scummex
In directory sc8-pr-cvs1:/tmp/cvs-serv1952
Modified Files:
image.cpp resource.cpp wxwindows.cpp wxwindows.h
Log Message:
Added zoom selection, now drawing images on a DC instead of a wxStaticBitmap which was slow and non-portable
Index: image.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/image.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- image.cpp 30 Sep 2003 11:41:28 -0000 1.22
+++ image.cpp 1 Oct 2003 10:06:11 -0000 1.23
@@ -168,7 +168,7 @@
}
if (_blockTable[id].image == NULL)
- _image = _blockTable[id].image = new ImageWindow("Boxes", wxSize(_width, _height), id);
+ _image = _blockTable[id].image = new ImageWindow("Boxes", wxSize(_width, _height), id, IMAGE_SCALE);
else
_image = _blockTable[id].image;
@@ -262,7 +262,7 @@
_height = _blockTable[id].height;
if (_blockTable[id].image == NULL)
- _image = _blockTable[id].image = new ImageWindow("SMUSH Frame", wxSize(_width, _height), id);
+ _image = _blockTable[id].image = new ImageWindow("SMUSH Frame", wxSize(_width, _height), id, IMAGE_SCALE);
else
_image = _blockTable[id].image;
@@ -333,7 +333,7 @@
_height = _blockTable[headerID].height;
if (_blockTable[id].image == NULL)
- _image = _blockTable[id].image = new ImageWindow("Room Image", wxSize(_width, _height), id, IMAGE_BOXES);
+ _image = _blockTable[id].image = new ImageWindow("Room Image", wxSize(_width, _height), id, IMAGE_BOXES|IMAGE_SCALE);
else
_image = _blockTable[id].image;
@@ -453,7 +453,7 @@
_height = _blockTable[headerID].height;
if (_blockTable[id].image == NULL)
- _image = _blockTable[id].image = new ImageWindow("Object", wxSize(_width, _height), id);
+ _image = _blockTable[id].image = new ImageWindow("Object", wxSize(_width, _height), id, IMAGE_SCALE);
else
_image = _blockTable[id].image;
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/resource.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- resource.cpp 30 Sep 2003 12:36:20 -0000 1.26
+++ resource.cpp 1 Oct 2003 10:06:11 -0000 1.27
@@ -34,6 +34,10 @@
int Resource::searchOldBlocks(BlockTable *_blockTable, File& _input, int index, int level, int size) {
int32 curpos = 0;
+ int called = 0;
+ if (size != 0)
+ called = 1;
+
if (size == 0)
size = _input.size();
@@ -59,6 +63,9 @@
_input.seek(size, SEEK_SET);
return index;
}
+ } else if (called) {
+ _input.seek(size, SEEK_SET);
+ return index;
}
curpos = _input.pos();
Index: wxwindows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- wxwindows.cpp 30 Sep 2003 11:41:28 -0000 1.34
+++ wxwindows.cpp 1 Oct 2003 10:06:11 -0000 1.35
@@ -149,20 +149,38 @@
return result;
}
+BEGIN_EVENT_TABLE(ImageScrolledWindow, wxScrolledWindow)
+ EVT_PAINT(ImageScrolledWindow::OnPaint)
+END_EVENT_TABLE()
+
+ImageScrolledWindow::ImageScrolledWindow(ImageWindow *imageWindow) : wxScrolledWindow (imageWindow, -1) {
+ _imageWindow = imageWindow;
+}
+
+void ImageScrolledWindow::OnPaint(wxPaintEvent &event) {
+ wxPaintDC dc(this);
+ PrepareDC(dc);
+ dc.DrawBitmap(wxBitmap(_imageWindow->_image), 0, 0);
+}
+
BEGIN_EVENT_TABLE(ImageWindow, wxFrame)
EVT_CLOSE(ImageWindow::OnQuit)
EVT_MENU(Viewer_Quit, ImageWindow::OnQuit)
EVT_MENU(ID_BMP, ImageWindow::SaveImage)
EVT_MENU(ID_Boxes, ImageWindow::boxesDrawOverlay)
+ EVT_MENU(ID_Scale1x, ImageWindow::Scale1x)
+ EVT_MENU(ID_Scale2x, ImageWindow::Scale2x)
+ EVT_MENU(ID_Scale3x, ImageWindow::Scale3x)
END_EVENT_TABLE()
ImageWindow::ImageWindow(const wxString& title, const wxSize& size, int blockId, byte flags, int scaleFactor)
- : wxFrame(_gui->_mainWindow, -1, title, wxPoint(-1,-1), size, wxDEFAULT_FRAME_STYLE & (wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION))
+ : wxFrame(_gui->_mainWindow, -1, title, wxPoint(-1,-1), size)
{
wxMenuBar *menuBar = new wxMenuBar;
wxMenu *menuFile = new wxMenu;
_blockId = blockId;
_boxesDisplayed = 0;
+ _clientSize = size;
wxMenuItem *BMPItem = new wxMenuItem(menuFile, ID_BMP, "Save to BMP...", "Save image to .BMP", wxITEM_NORMAL, NULL );
wxBitmap SaveIcon = wxBitmap(save_icon);
@@ -173,14 +191,7 @@
menuBar->Append(menuFile,"&File");
- if (flags & IMAGE_BOXES) {
- wxMenu *menuView = new wxMenu;
- wxMenuItem *BoxesItem = new wxMenuItem(menuView, ID_Boxes, "Display Boxes", "Display Boxes", wxITEM_CHECK, NULL );
- menuView->Append(BoxesItem);
- menuBar->Append(menuView,"View");
- }
-
- SetMenuBar(menuBar);
+ wxMenu *menuView = new wxMenu;
if (scaleFactor == 0) {
_scaleFactor = 1;
@@ -188,24 +199,122 @@
} else {
_scaleFactor = scaleFactor;
}
+
+ if (flags & IMAGE_BOXES) {
+ menuView->AppendCheckItem(ID_Boxes, "Display Boxes", "Display Boxes");
+ }
- SetClientSize(size.GetWidth() * _scaleFactor, size.GetHeight() * _scaleFactor);
+ if (flags & IMAGE_SCALE) {
+ menuZoom = new wxMenu;
+ menuZoom->AppendCheckItem(ID_Scale1x, "100%", "100%");
+ menuZoom->AppendCheckItem(ID_Scale2x, "200%", "200%");
+ menuZoom->AppendCheckItem(ID_Scale3x, "300%", "300%");
+ menuView->Append(ID_Zoom, "Zoom", menuZoom, "Zoom");
+ switch(_scaleFactor) {
+ case 1:
+ menuZoom->Check(ID_Scale1x, TRUE);
+ break;
+
+ case 2:
+ menuZoom->Check(ID_Scale2x, TRUE);
+ break;
+
+ case 3:
+ menuZoom->Check(ID_Scale3x, TRUE);
+ break;
+ }
+ }
+
+ menuBar->Append(menuView,"View");
+ SetMenuBar(menuBar);
+
+ SetClientSize(size.GetWidth() * _scaleFactor+20, size.GetHeight() * _scaleFactor+20);
_image = new wxImage(size.GetWidth() * _scaleFactor, size.GetHeight() * _scaleFactor);
- _sbmp = NULL;
+
+ _imageScrolledWindow = new ImageScrolledWindow(this);
+
+ _imageScrolledWindow->SetVirtualSize(size.GetWidth() * _scaleFactor, size.GetHeight() * _scaleFactor);
+ _imageScrolledWindow->SetScrollRate(10, 10);
+ SetSizeHints(130, 80, wxSystemSettings::GetMetric(wxSYS_SCREEN_X) - 25, wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) - 25);
}
void ImageWindow::DrawImage() {
- wxBitmap bitmap = wxBitmap(_image);
+ wxClientDC dc(this);
+ dc.DrawBitmap(wxBitmap(_image), 0, 0);
+ Show(TRUE);
+ Refresh();
+}
+
+void ImageWindow::Scale1x(wxEvent& event) {
+ _scaleFactor = 1;
+ menuZoom->Check(ID_Scale2x, FALSE);
+ menuZoom->Check(ID_Scale3x, FALSE);
+ Scale();
+}
+
+void ImageWindow::Scale2x(wxEvent& event) {
+ _scaleFactor = 2;
+ menuZoom->Check(ID_Scale1x, FALSE);
+ menuZoom->Check(ID_Scale3x, FALSE);
+ Scale();
+}
+
+void ImageWindow::Scale3x(wxEvent& event) {
+ _scaleFactor = 3;
+ menuZoom->Check(ID_Scale1x, FALSE);
+ menuZoom->Check(ID_Scale2x, FALSE);
+ Scale();
+}
+
+void ImageWindow::Scale() {
+ delete _image;
+ _image = new wxImage(_clientSize.GetWidth() * _scaleFactor, _clientSize.GetHeight() * _scaleFactor);
+
+ SetClientSize(_clientSize.GetWidth() * _scaleFactor+20, _clientSize.GetHeight() * _scaleFactor+20);
+ _imageScrolledWindow->SetVirtualSize(_clientSize.GetWidth() * _scaleFactor, _clientSize.GetHeight() * _scaleFactor);
- if (_sbmp == NULL) {
- wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL );
+ switch (g_scummex->getBlockTable(_blockId).blockTypeID) {
+ case IM01:
+ case IM02:
+ case IM03:
+ case IM04:
+ case IM05:
+ case IM06:
+ case IM07:
+ case IM08:
+ case IM09:
+ case IM0A:
+ case IM0B:
+ case IM0C:
+ case IM0D:
+ case IM0E:
+ case IM0F:
+ case OI:
+ case OBIM:
+ g_scummex->objectDraw(_blockId);
+ break;
- _sbmp = new wxStaticBitmap(this, -1, bitmap);
- vertSizer->Add(_sbmp, 0, wxALL, 0 );
- Show(TRUE);
- } else {
- _sbmp->SetBitmap(bitmap);
- Refresh();
+ case CLUT:
+ case APAL:
+ case PA:
+ case NPAL:
+ case AHDR:
+ case RGBS:
+ g_scummex->paletteDraw(_blockId);
+ break;
+
+ case BM:
+ case RMIM:
+ case IMAG:
+ g_scummex->bgDraw(_blockId);
+ if (_boxesDisplayed)
+ g_scummex->boxesDraw(_blockId);
+ break;
+
+ case BOXD:
+ case BX:
+ g_scummex->boxesDraw(_blockId);
+ break;
}
}
Index: wxwindows.h
===================================================================
RCS file: /cvsroot/scummvm/scummex/wxwindows.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- wxwindows.h 30 Sep 2003 00:38:43 -0000 1.16
+++ wxwindows.h 1 Oct 2003 10:06:12 -0000 1.17
@@ -41,9 +41,12 @@
enum {
FLAG_NONE = 1 << 0,
- IMAGE_BOXES = 1 << 1
+ IMAGE_BOXES = 1 << 1,
+ IMAGE_SCALE = 1 << 2
};
-
+
+class ImageScrolledWindow;
+
class MainWindow : public wxFrame {
private:
wxHtmlHelpController *HtmlHelp;
@@ -105,21 +108,38 @@
class ImageWindow : public wxFrame {
public:
int _scaleFactor;
+ wxSize _clientSize;
+ wxImage *_image;
+ wxMenu *menuZoom;
ImageWindow(const wxString& title, const wxSize& size, int blockId, byte flags = FLAG_NONE, int scaleFactor = 0);
void DrawImage();
void PutPixel(int x, int y, int red, int green, int blue);
protected:
- wxStaticBitmap *_sbmp;
- wxImage *_image;
+ ImageScrolledWindow *_imageScrolledWindow;
+
int _blockId;
int _boxesDisplayed;
void OnQuit(wxCommandEvent& event);
-
void SaveImage(wxEvent& event);
void boxesDrawOverlay(wxEvent& event);
+ void Scale1x(wxEvent& event);
+ void Scale2x(wxEvent& event);
+ void Scale3x(wxEvent& event);
+ void Scale();
+
+ DECLARE_EVENT_TABLE()
+};
+
+class ImageScrolledWindow : public wxScrolledWindow {
+public:
+ ImageScrolledWindow(ImageWindow *imageWindow);
+
+protected:
+ ImageWindow *_imageWindow;
+ void OnPaint(wxPaintEvent &event);
DECLARE_EVENT_TABLE()
};
@@ -185,7 +205,11 @@
ID_ViewerWindow,
ID_BMP,
ID_Boxes,
- ID_Tree
+ ID_Tree,
+ ID_Scale1x,
+ ID_Scale2x,
+ ID_Scale3x,
+ ID_Zoom
};
extern GUI_wxWindows *_gui;
More information about the Scummvm-git-logs
mailing list