[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/caimagemanipulation caimagemanipulati
From: |
Ingo Ruhnke |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/caimagemanipulation caimagemanipulation.cpp, 1.6, 1.7 caimagemanipulation.h, 1.6, 1.7 |
Date: |
Sun, 19 Oct 2003 14:25:49 +0200 |
Update of /var/lib/cvs/Games/Pingus/src/caimagemanipulation
In directory dark:/tmp/cvs-serv19578/caimagemanipulation
Modified Files:
caimagemanipulation.cpp caimagemanipulation.h
Log Message:
- some more stuff, still not much useable
Index: caimagemanipulation.cpp
===================================================================
RCS file:
/var/lib/cvs/Games/Pingus/src/caimagemanipulation/caimagemanipulation.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- caimagemanipulation.cpp 18 Oct 2003 23:17:27 -0000 1.6
+++ caimagemanipulation.cpp 19 Oct 2003 12:25:47 -0000 1.7
@@ -18,128 +18,33 @@
#include <cmath>
#include <ClanLib/display.h>
+#include "../canvas.hxx"
#include "caimagemanipulation.h"
-/** Returns a pointer to a new image, based on 'surface'
- but rotated by an angle of 'degrees' degrees.
- \param surface The original surface
- \param angle Rotation angle in degrees (clock-wise)
- \param exact true: Exact, smooth coloring (calculates color 'between'
pixels)
- false: Inexact but faster.
-*/
-CL_Surface*
-CAImageManipulation::rotate( CL_Surface* surface,
- float angle,
- bool exact )
-{
- int width = surface->get_width();
- int height = surface->get_height();
-
- // Create a temporary canvas which contains the original surface:
- CL_Canvas* tmpCan = new CL_Canvas( width, height );
- surface->put_target( 0,0, 0, tmpCan );
-
- // Create a new canvas which will contain the rotated surface:
- CL_Canvas* newCan = new CL_Canvas( width, height );
-
- // Calc size in bytes:
- int bpp = tmpCan->get_bytes_per_pixel();
- int size = width * height * bpp;
-
- // Only 24bit supported:
- //
- if( bpp==4 ) {
-
- newCan->lock();
-
- int i; // i is the index for the rotated data
- int r, g, b, a;
- float xo, yo; // Original pixel
- float xr, yr; // Rotated pixel
- float cx, cy; // Rotation center
-
- r=g=b=a=0;
-
- cx = (float)width/2;
- cy = (float)height/2;
-
- // Store original image:
- //
- unsigned char *oriData = (unsigned char*)tmpCan->get_data();
- unsigned char *newData = (unsigned char*)newCan->get_data();
-
- // needs to be calculated only once since angle doesn't change!!
- //
- float cos_angle = cos( angle/ARAD ); // rotating it clockwise (!) by
angle,
- float sin_angle = sin( angle/ARAD );
-
- float x0;
- float y0;
-
- // Rotate:
- //
- for( i=0; i<size; i+=bpp ) {
- xr = getCoordinateX( width, i );
- yr = getCoordinateY( width, i );
-
- x0 = (xr - cx); // rotation around origin, so i create a relative
- y0 = (yr - cy); // vector by subtracting (cx, cy) ...
-
- xo = cx + x0 * cos_angle + y0 * sin_angle; // ... and add it again
after rotation
- yo = cy + y0 * cos_angle - x0 * sin_angle;
-
- if( (int)xo>-0.5 && (int)xo<width+0.5 &&
- (int)yo>-0.5 && (int)yo<height+0.5 ) {
-
- getExactColor( oriData,
- width, height,
- xo, yo,
- &r, &g, &b, &a,
- exact );
-
- newData[i ] = a;
- newData[i+1] = b;
- newData[i+2] = g;
- newData[i+3] = r;
- }
- else {
- newData[i ] = 0;
- newData[i+1] = 0;
- newData[i+2] = 0;
- newData[i+3] = 0;
- }
- }
- newCan->unlock();
- }
- delete tmpCan;
-
- // Return new surface based on the canvas:
- //
- return CL_Surface::create( newCan );
-}
-
-
+using namespace Pingus;
/** Returns a pointer to a new image, based on 'surface'
but fliped horizontal or vertical.
\param horizontal true: Flip horizontal (left to right)
false: Flip vertical (upsidedown)
*/
-CL_Surface*
-CAImageManipulation::flip( CL_Surface* surface, bool horizontal )
+CL_Surface
+CAImageManipulation::flip( CL_Surface surface, bool horizontal )
{
// Create a canvas which contains the original surface:
//
- CL_Canvas* can = new CL_Canvas( surface->get_width(),
- surface->get_height() );
-
- surface->put_target( 0,0, 0, can );
+ CL_PixelBuffer* can = Canvas::create_rgba8888(surface.get_width(),
surface.get_height());
+
+ // FIXME:
+ assert(0);
+ // surface->put_target( 0,0, 0, can );
// Calc size in bytes:
//
- int bpp = can->get_bytes_per_pixel();
- int size = surface->get_width() * surface->get_height() * bpp;
- int width = surface->get_width();
+ int bpp = 0;// FIXME: can->get_bytes_per_pixel();
+
+ int size = surface.get_width() * surface.get_height() * bpp;
+ int width = surface.get_width();
// Only 24bit supported:
//
@@ -180,7 +85,7 @@
// Return new surface based on the canvas:
//
- return CL_Surface::create( can );
+ return CL_Surface( can );
}
@@ -199,21 +104,22 @@
\param saturation Changing of saturation: -100...100
\param value Changing of value (Color intensity): -100...100
*/
-CL_Surface*
-CAImageManipulation::changeHSV( CL_Surface* surface,
- int hue, int saturation, int value )
+CL_Surface
+CAImageManipulation::changeHSV(CL_Surface surface,
+ int hue, int saturation, int value)
{
// Create a canvas which contains the original surface:
//
- CL_Canvas* can = new CL_Canvas( surface->get_width(),
- surface->get_height() );
+ CL_PixelBuffer* can = Canvas::create_rgba8888(surface.get_width(),
+ surface.get_height());
- surface->put_target( 0,0, 0, can );
+ assert(0);
+ // FIXME: surface->put_target( 0,0, 0, can );
// Calc size in bytes:
//
- int bpp = can->get_bytes_per_pixel();
- int size = surface->get_width() * surface->get_height() * bpp;
+ int bpp = 0;// FIXME: can->get_bytes_per_pixel();
+ int size = surface.get_width() * surface.get_height() * bpp;
// Only 24bit supported:
//
@@ -258,7 +164,7 @@
// Return new surface based on the canvas:
//
- return CL_Surface::create( can );
+ return CL_Surface( can );
}
Index: caimagemanipulation.h
===================================================================
RCS file:
/var/lib/cvs/Games/Pingus/src/caimagemanipulation/caimagemanipulation.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- caimagemanipulation.h 27 Sep 2002 11:26:45 -0000 1.6
+++ caimagemanipulation.h 19 Oct 2003 12:25:47 -0000 1.7
@@ -40,9 +40,8 @@
CAImageManipulation();
~CAImageManipulation();
- static CL_Surface* rotate( CL_Surface* surface, float angle, bool exact=true
);
- static CL_Surface* flip( CL_Surface* surface, bool horizontal );
- static CL_Surface* changeHSV( CL_Surface* surface, int hue, int saturation,
int value );
+ static CL_Surface flip( CL_Surface surface, bool horizontal );
+ static CL_Surface changeHSV( CL_Surface surface, int hue, int saturation,
int value );
static void rgbToHsv( int r, int g, int b,
int *h, int *s, int *v );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/caimagemanipulation caimagemanipulation.cpp, 1.6, 1.7 caimagemanipulation.h, 1.6, 1.7,
Ingo Ruhnke <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src Makefile.am, 1.154, 1.155 blitter.cxx, 1.31, 1.32 blitter.hxx, 1.11, 1.12 blitter_impl.hxx, 1.13, 1.14 indexed_canvas.hxx, 1.4, 1.5 loading.hxx, 1.7, 1.8 menu_button.hxx, 1.4, 1.5 pingu_map.cxx, 1.8, 1.9 pingus_counter.hxx, 1.11, 1.12 pingus_counter_bar.cxx, 1.7, 1.8 pingus_main.cxx, 1.99, 1.100 pingus_map_manager.cxx, 1.4, 1.5 pingus_menu.cxx, 1.21, 1.22 pingus_menu_manager.cxx, 1.26, 1.27 pingus_resource.hxx, 1.16, 1.17 playfield.cxx, 1.36, 1.37 playfield_view.hxx, 1.9, 1.10 plt_xml.cxx, 1.12, 1.13 prefab.cxx, 1.7, 1.8 resource_modifier.cxx, 1.3, 1.4 screenshot.cxx, 1.15, 1.16 smallmap.hxx, 1.19, 1.20 theme_selector.hxx, 1.7, 1.8 vector.cxx, 1.5, 1.6 view.cxx, 1.14, 1.15 view.hxx, 1.13, 1.14 worldobj.cxx, 1.12, 1.13 worldobj_data_factory.hxx, 1.9, 1.10 xml_plf.cxx, 1.39, 1.40
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs/entrances cloud.cxx, 1.3, 1.4 woodthing.cxx, 1.8, 1.9 woodthing.hxx, 1.4, 1.5
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src Makefile.am, 1.154, 1.155 blitter.cxx, 1.31, 1.32 blitter.hxx, 1.11, 1.12 blitter_impl.hxx, 1.13, 1.14 indexed_canvas.hxx, 1.4, 1.5 loading.hxx, 1.7, 1.8 menu_button.hxx, 1.4, 1.5 pingu_map.cxx, 1.8, 1.9 pingus_counter.hxx, 1.11, 1.12 pingus_counter_bar.cxx, 1.7, 1.8 pingus_main.cxx, 1.99, 1.100 pingus_map_manager.cxx, 1.4, 1.5 pingus_menu.cxx, 1.21, 1.22 pingus_menu_manager.cxx, 1.26, 1.27 pingus_resource.hxx, 1.16, 1.17 playfield.cxx, 1.36, 1.37 playfield_view.hxx, 1.9, 1.10 plt_xml.cxx, 1.12, 1.13 prefab.cxx, 1.7, 1.8 resource_modifier.cxx, 1.3, 1.4 screenshot.cxx, 1.15, 1.16 smallmap.hxx, 1.19, 1.20 theme_selector.hxx, 1.7, 1.8 vector.cxx, 1.5, 1.6 view.cxx, 1.14, 1.15 view.hxx, 1.13, 1.14 worldobj.cxx, 1.12, 1.13 worldobj_data_factory.hxx, 1.9, 1.10 xml_plf.cxx, 1.39, 1.40
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs/entrances cloud.cxx, 1.3, 1.4 woodthing.cxx, 1.8, 1.9 woodthing.hxx, 1.4, 1.5
- Index(es):