Added rotation to wxImage

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2000-02-06 14:51:36 +00:00
parent 12c1b46a2f
commit 7a632f1056
13 changed files with 454 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#
# File: makefile.unx
# Author: Julian Smart
# Created: 1998
# Updated:
# Copyright: (c) 1998 Julian Smart
#
# "%W% %G%"
#
# Makefile for rotate example (UNIX).
top_srcdir = @top_srcdir@/..
top_builddir = ../..
program_dir = samples/rotate
PROGRAM=rotate
OBJECTS=$(PROGRAM).o
include ../../src/makeprog.env

BIN
samples/rotate/kclub.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,16 @@
#
# File: makefile.b32
# Author: Julian Smart
# Created: 1999
# Updated:
# Copyright:
#
# Makefile : Builds sample for 32-bit BC++
WXDIR = $(WXWIN)
TARGET=rotate
OBJECTS = $(TARGET).obj
!include $(WXDIR)\src\makeprog.b32

View File

@@ -0,0 +1,16 @@
#
# File: makefile.g95
# Author: Julian Smart
# Created: 1999
# Updated:
# Copyright: (c) Julian Smart, 1999
#
# Makefile for wxWindows sample (Cygwin/Mingw32).
WXDIR = ../..
TARGET=rotate
OBJECTS = $(TARGET).o
include $(WXDIR)/src/makeprog.g95

View File

@@ -0,0 +1,35 @@
#
# File: Makefile for samples
# Author: Robert Roebling
# Created: 1999
# Updated:
# Copyright: (c) 1998 Robert Roebling
#
# This makefile requires a Unix version of wxWindows
# to be installed on your system. This is most often
# done typing "make install" when using the complete
# sources of wxWindows or by installing the two
# RPM packages wxGTK.XXX.rpm and wxGTK-devel.XXX.rpm
# under Linux.
#
CC = gcc
PROGRAM = rotate
OBJECTS = $(PROGRAM).o
# implementation
.SUFFIXES: .o .cpp
.cpp.o :
$(CC) -c `wx-config --cflags` -o $@ $<
all: $(PROGRAM)
$(PROGRAM): $(OBJECTS)
$(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`
clean:
rm -f *.o $(PROGRAM)

View File

@@ -0,0 +1,18 @@
#
# File: makefile.vc
# Author: Julian Smart
# Created: 1999
# Updated:
# Copyright: (c) Julian Smart
#
# Makefile : Builds sample (VC++, WIN32)
# Use FINAL=1 argument to nmake to build final version with no debug info.
# Set WXDIR for your system
WXDIR = $(WXWIN)
PROGRAM=rotate
OBJECTS = $(PROGRAM).obj
!include $(WXDIR)\src\makeprog.vc

View File

@@ -0,0 +1,15 @@
#
# Makefile for WATCOM
#
# Created by Julian Smart, January 1999
#
#
WXDIR = $(%WXWIN)
PROGRAM = rotate
OBJECTS = $(PROGRAM).obj
!include $(WXDIR)\src\makeprog.wat

BIN
samples/rotate/mondrian.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

120
samples/rotate/rotate.cpp Normal file
View File

@@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////////////
// Name: test.cpp
// Purpose: Image rotation test
// Author: Carlos Moreno
// Modified by:
// Created: 6/2/2000
// RCS-ID: $Id$
// Copyright: (c) 2000
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/image.h"
class MyApp: public wxApp
{
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit (wxCommandEvent &);
void OnMouseLeftUp (wxMouseEvent & event);
void OnMouseRightUp (wxMouseEvent & event);
private:
DECLARE_EVENT_TABLE()
};
enum
{
ID_Quit = 1
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU (ID_Quit, MyFrame::OnQuit)
EVT_LEFT_UP (MyFrame::OnMouseLeftUp)
EVT_RIGHT_UP (MyFrame::OnMouseRightUp)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame ("wxWindows Skeleton", wxPoint(20,20), wxSize(600,450));
frame->SetBackgroundColour (wxColour (0,80,60));
frame->Show (TRUE);
SetTopWindow (frame);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
wxMenu *menuFile = new wxMenu;
menuFile->Append (ID_Quit, "E&xit");
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append (menuFile, "&File");
SetMenuBar (menuBar);
}
void MyFrame::OnQuit (wxCommandEvent &)
{
Close (TRUE);
}
// Rotate with interpolation and with offset correction
void MyFrame::OnMouseLeftUp (wxMouseEvent & event)
{
static double angle = 0.1;
const double pi = 3.14159265359;
wxImage img ("kclub.bmp", wxBITMAP_TYPE_BMP);
wxPoint offset;
wxImage img2 = img.Rotate(angle, wxPoint(img.GetWidth()/2, img.GetHeight()/2), TRUE, &offset);
angle += 0.05;
wxBitmap bmp = img2.ConvertToBitmap ();
wxClientDC dc (this);
dc.DrawBitmap (bmp, event.m_x + offset.x, event.m_y + offset.y);
return;
}
// without interpolation, and without offset correction
void MyFrame::OnMouseRightUp (wxMouseEvent & event)
{
static double angle = 0.1;
const double pi = 3.14159265359;
wxImage img ("kclub.bmp", wxBITMAP_TYPE_BMP);
wxImage img2 = img.Rotate(angle, wxPoint(img.GetWidth()/2, img.GetHeight()/2), FALSE);
angle += 0.05;
wxBitmap bmp = img2.ConvertToBitmap ();
wxClientDC dc (this);
dc.DrawBitmap (bmp, event.m_x, event.m_y);
return;
}

3
samples/rotate/rotate.rc Normal file
View File

@@ -0,0 +1,3 @@
mondrian ICON "mondrian.ico"
#include "wx/msw/wx.rc"