[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] rev 2308 - in trunk: data/data src src/caimagemanipulation
From: |
Ingo Ruhnke |
Subject: |
[Pingus-CVS] rev 2308 - in trunk: data/data src src/caimagemanipulation src/editor src/gui |
Date: |
Thu, 06 May 2004 22:57:37 +0200 |
Author: grumbel
Date: 2004-05-06 22:57:36 +0200 (Thu, 06 May 2004)
New Revision: 2308
Removed:
trunk/src/canvas.cxx
trunk/src/canvas.hxx
Modified:
trunk/data/data/core.xml
trunk/src/Makefile.am
trunk/src/blitter.cxx
trunk/src/blitter.hxx
trunk/src/blitter_impl.hxx
trunk/src/caimagemanipulation/caimagemanipulation.cpp
trunk/src/col_map.cxx
trunk/src/editor/thumb_cache.cxx
trunk/src/gui/buffer_graphic_context.cxx
trunk/src/gui/buffer_graphic_context.hxx
trunk/src/pingus_counter.cxx
trunk/src/pingus_counter.hxx
trunk/src/pingus_resource.cxx
trunk/src/screenshot.cxx
trunk/src/screenshot.hxx
trunk/src/smallmap.cxx
trunk/src/smallmap.hxx
trunk/src/smallmap_image.cxx
trunk/src/spot_map.cxx
trunk/src/world.cxx
Log:
- more CL0.7 stuff
Modified: trunk/data/data/core.xml
===================================================================
--- trunk/data/data/core.xml 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/data/data/core.xml 2004-05-06 20:57:36 UTC (rev 2308)
@@ -34,7 +34,11 @@
<surface file="../images/core/editor/logo.png" name="logo" />
</section>
<section name="buttons">
- <surface file="../images/core/buttons/info.png" name="info" />
+ <sprite name="info">
+ <translation origin="top_center" />
+ <image file="../images/core/buttons/info.png" />
+ </sprite>
+
<surface file="../images/core/buttons/hbuttonbg.png" name="hbuttonbg" />
<surface file="../images/core/buttons/hbuttonbgb.png" name="hbuttonbgb" />
<surface file="../images/core/buttons/buttonbackground.png"
name="buttonbackground" />
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/Makefile.am 2004-05-06 20:57:36 UTC (rev 2308)
@@ -95,8 +95,6 @@
blitter_impl.hxx \
button_panel.cxx \
button_panel.hxx \
-canvas.hxx \
-canvas.cxx \
capture_rectangle.cxx \
capture_rectangle.hxx \
cheat.hxx \
Modified: trunk/src/blitter.cxx
===================================================================
--- trunk/src/blitter.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/blitter.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -20,6 +20,7 @@
#include <config.h>
#include <stdio.h>
#include <assert.h>
+#include <ClanLib/Core/IOData/datatypes.h>
#include <ClanLib/Display/palette.h>
#include <ClanLib/Display/pixel_buffer.h>
#include <ClanLib/Display/pixel_format.h>
@@ -41,14 +42,14 @@
namespace Pingus {
void
-Blitter::put_surface(CL_PixelBuffer& canvas, const CL_Surface& sur,
+Blitter::put_surface(CL_PixelBuffer canvas, const CL_Surface& sur,
int x, int y)
{
Blitter::put_surface(canvas, sur.get_pixeldata(), x, y);
}
void
-Blitter::put_surface(CL_PixelBuffer& canvas, const CL_PixelBuffer& provider,
+Blitter::put_surface(CL_PixelBuffer canvas, CL_PixelBuffer provider,
int x, int y)
{
switch(provider.get_format().get_depth())
@@ -66,11 +67,9 @@
}
void
-Blitter::put_surface_8bit(CL_PixelBuffer& provider, const CL_PixelBuffer&
sprovider_,
+Blitter::put_surface_8bit(CL_PixelBuffer provider, CL_PixelBuffer sprovider,
int x, int y)
{
- CL_PixelBuffer sprovider = sprovider_;
-
int start_i;
unsigned char* tbuffer; // Target buffer
int twidth, theight, tpitch;
@@ -110,6 +109,8 @@
if (sprovider.get_format().has_colorkey ())
{
+ std::cout << "8bit blit: " << twidth << "x" << theight << " " << swidth
<< "x" << sheight << std::endl;
+
unsigned int colorkey = sprovider.get_format().get_colorkey();
for(int line=y_offset;
@@ -126,15 +127,17 @@
if (sbuffer[j] != colorkey)
{
tbuffer[i + 0] = 255; //
alpha
- tbuffer[i + 1] = palette.colors[sbuffer[j] * 3].get_blue();
// blue
- tbuffer[i + 2] = palette.colors[sbuffer[j] * 3].get_green();
// green
- tbuffer[i + 3] = palette.colors[sbuffer[j] * 3].get_red(); //
red
+ tbuffer[i + 1] = palette.colors[cl_uint8(sbuffer[j] *
3)].get_blue(); // blue
+ tbuffer[i + 2] = palette.colors[cl_uint8(sbuffer[j] *
3)].get_green(); // green
+ tbuffer[i + 3] = palette.colors[cl_uint8(sbuffer[j] *
3)].get_red(); // red
}
}
}
}
else
{
+ std::cout << "8bit blit: " << twidth << "x" << theight << " " << swidth
<< "x" << sheight << std::endl;
+
for(int line=y_offset;
line < sheight && (line + y) < theight;
++line)
@@ -147,9 +150,9 @@
i += 4, ++j)
{
tbuffer[i + 0] = 255; // alpha
- tbuffer[i + 1] = palette[sbuffer[j] * 3 + 2]; // blue
- tbuffer[i + 2] = palette[sbuffer[j] * 3 + 1]; // green
- tbuffer[i + 3] = palette[sbuffer[j] * 3 + 0]; // red
+ tbuffer[i + 1] = palette[cl_uint8(sbuffer[j] * 3 + 2)]; // blue
+ tbuffer[i + 2] = palette[cl_uint8(sbuffer[j] * 3 + 1)]; // green
+ tbuffer[i + 3] = palette[cl_uint8(sbuffer[j] * 3 + 0)]; // red
}
}
}
@@ -159,7 +162,7 @@
}
void
-Blitter::put_surface_32bit(CL_PixelBuffer& canvas, const CL_PixelBuffer&
provider_,
+Blitter::put_surface_32bit(CL_PixelBuffer canvas, CL_PixelBuffer provider_,
const int x_pos, const int y_pos)
{
CL_PixelBuffer provider = provider_;
@@ -212,7 +215,7 @@
}
void
-Blitter::put_alpha_surface(CL_PixelBuffer& provider, CL_PixelBuffer& sprovider,
+Blitter::put_alpha_surface(CL_PixelBuffer provider, CL_PixelBuffer sprovider,
int x, int y)
{
int start_i;
@@ -276,7 +279,7 @@
}
CL_PixelBuffer
-Blitter::clear_canvas(CL_PixelBuffer& canvas)
+Blitter::clear_canvas(CL_PixelBuffer canvas)
{
unsigned char* buffer;
@@ -346,7 +349,7 @@
Blitter::scale_surface (const CL_Surface& sur, int width, int height)
{
CL_PixelBuffer buf = Blitter::scale_surface_to_canvas(sur, width, height);
- return CL_Surface(&buf, false);
+ return CL_Surface(new CL_PixelBuffer(buf), true);
}
CL_PixelBuffer
Modified: trunk/src/blitter.hxx
===================================================================
--- trunk/src/blitter.hxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/blitter.hxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -34,10 +34,10 @@
{
private:
///
- static void put_surface_8bit(CL_PixelBuffer& target, const CL_PixelBuffer&
source,
+ static void put_surface_8bit(CL_PixelBuffer target, CL_PixelBuffer source,
int x, int y);
///
- static void put_surface_32bit(CL_PixelBuffer& target, const CL_PixelBuffer&
source,
+ static void put_surface_32bit(CL_PixelBuffer target, CL_PixelBuffer source,
int x, int y);
public:
/*void put_surface(CL_LockableSurface* provider, CL_Surface surface,
@@ -47,16 +47,16 @@
*/
/// Puts a given surface to a given canvas at position x, y.
- static void put_surface(CL_PixelBuffer& target, const CL_Surface& source,
+ static void put_surface(CL_PixelBuffer target, const CL_Surface& source,
int x, int y);
/// Puts a given surface provider to a given canvas at position x, y.
- static void put_surface(CL_PixelBuffer& target, const CL_PixelBuffer& source,
+ static void put_surface(CL_PixelBuffer target, CL_PixelBuffer source,
int x, int y);
/** Makes all pixels in canvas tranparent, when their indexed value
in provider is larger than zero.*/
- static void put_alpha_surface(CL_PixelBuffer& target, CL_PixelBuffer& source,
+ static void put_alpha_surface(CL_PixelBuffer target, CL_PixelBuffer source,
int x, int y);
/** Returns a newly allocated canvas. The canvas contains the same
@@ -68,7 +68,7 @@
static CL_PixelBuffer create_canvas(CL_PixelBuffer );
/** Sets all pixels of a canvas to zero */
- static CL_PixelBuffer clear_canvas(CL_PixelBuffer& );
+ static CL_PixelBuffer clear_canvas(CL_PixelBuffer );
/** Creates a new surface (based on a canvas) with the given width
and height and stretches the source surface onto it
Modified: trunk/src/blitter_impl.hxx
===================================================================
--- trunk/src/blitter_impl.hxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/blitter_impl.hxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -24,7 +24,6 @@
#include <ClanLib/Display/pixel_buffer.h>
#include <ClanLib/Display/surface.h>
#include "pingus.hxx"
-#include "canvas.hxx"
namespace Pingus {
@@ -214,7 +213,7 @@
canvas.unlock ();
prov.unlock ();
- return CL_Surface(&canvas, false);
+ return CL_Surface(new CL_PixelBuffer(&canvas), true);
#endif
return CL_Surface();
}
@@ -239,7 +238,7 @@
canvas.unlock ();
prov.unlock ();
- return CL_Surface(&canvas, false);
+ return CL_Surface(new CL_PixelBuffer(canvas), true);
}
}
Modified: trunk/src/caimagemanipulation/caimagemanipulation.cpp
===================================================================
--- trunk/src/caimagemanipulation/caimagemanipulation.cpp 2004-05-06
18:53:10 UTC (rev 2307)
+++ trunk/src/caimagemanipulation/caimagemanipulation.cpp 2004-05-06
20:57:36 UTC (rev 2308)
@@ -19,11 +19,8 @@
#include <assert.h>
#include <cmath>
#include <ClanLib/display.h>
-#include "../canvas.hxx"
#include "caimagemanipulation.h"
-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)
@@ -34,7 +31,8 @@
{
// Create a canvas which contains the original surface:
//
- CL_PixelBuffer* can = Canvas::create_rgba8888(surface.get_width(),
surface.get_height());
+ CL_PixelBuffer* can = new CL_PixelBuffer(surface.get_width(),
surface.get_height(),
+ surface.get_width()*4,
CL_PixelFormat::rgba8888);
// FIXME:
assert(0);
@@ -111,8 +109,8 @@
{
// Create a canvas which contains the original surface:
//
- CL_PixelBuffer* can = Canvas::create_rgba8888(surface.get_width(),
- surface.get_height());
+ CL_PixelBuffer* can = new CL_PixelBuffer(surface.get_width(),
surface.get_height(),
+ surface.get_width()*4,
CL_PixelFormat::rgba8888);
assert(0);
// FIXME: surface->put_target( 0,0, 0, can );
Deleted: trunk/src/canvas.cxx
===================================================================
--- trunk/src/canvas.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/canvas.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -1,34 +0,0 @@
-// $Id: canvas.cxx,v 1.1 2004/04/02 18:08:56 grumbel Exp $
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include <ClanLib/Display/pixel_format.h>
-#include "canvas.hxx"
-
-namespace Pingus {
-
-CL_PixelBuffer*
-Canvas::create_rgba8888(int w, int h)
-{
- return new CL_PixelBuffer(w, h, w*4,
- CL_PixelFormat::rgba8888);
-}
-
-} // namespace Pingus
-
-/* EOF */
Deleted: trunk/src/canvas.hxx
===================================================================
--- trunk/src/canvas.hxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/canvas.hxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -1,39 +0,0 @@
-// $Id: canvas.hxx,v 1.1 2004/04/02 18:08:56 grumbel Exp $
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef HEADER_CANVAS_HXX
-#define HEADER_CANVAS_HXX
-
-#include <ClanLib/Display/pixel_buffer.h>
-
-namespace Pingus {
-
-/** */
-class Canvas
-{
-private:
-public:
- static CL_PixelBuffer* create_rgba8888(int w, int h);
-};
-
-} // namespace Pingus
-
-#endif
-
-/* EOF */
Modified: trunk/src/col_map.cxx
===================================================================
--- trunk/src/col_map.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/col_map.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -25,7 +25,6 @@
#include "gui/graphic_context.hxx"
#include "globals.hxx"
#include "col_map.hxx"
-#include "canvas.hxx"
#include "gettext.h"
#define COLMAP_WITH_MEMORY_HOLE 1
@@ -254,12 +253,12 @@
void
ColMap::draw(GraphicContext& gc)
{
- CL_PixelBuffer* canvas = Canvas::create_rgba8888(width, height);
+ CL_PixelBuffer canvas(width, height, width*4, CL_PixelFormat::rgba8888);
CL_Surface sur;
unsigned char* buffer;
- canvas->lock();
- buffer = static_cast<unsigned char*>(canvas->get_data());
+ canvas.lock();
+ buffer = static_cast<unsigned char*>(canvas.get_data());
for(int i = 0; i < (width * height); ++i)
{
@@ -295,12 +294,9 @@
}
}
- // FIXME: Memory hole
-#if COLMAP_WITH_MEMORY_HOLE
- canvas->unlock();
-#endif
+ canvas.unlock();
- sur = CL_Surface(canvas, true);
+ sur = CL_Surface(new CL_PixelBuffer(canvas), true);
gc.draw(sur, 0, 0);
}
Modified: trunk/src/editor/thumb_cache.cxx
===================================================================
--- trunk/src/editor/thumb_cache.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/editor/thumb_cache.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -25,7 +25,6 @@
#include "../globals.hxx"
#include "../blitter.hxx"
#include "../system.hxx"
-#include "../canvas.hxx"
#include "../debug.hxx"
#include "../pingus_resource.hxx"
#include "../math.hxx"
@@ -98,9 +97,9 @@
return uncached_load (res_ident, datafile);
}
- CL_PixelBuffer* canvas = Canvas::create_rgba8888(width, height);
- canvas->lock ();
- void* buffer = canvas->get_data ();
+ CL_PixelBuffer canvas(width, height, width*4,
CL_PixelFormat::rgba8888);
+ canvas.lock ();
+ void* buffer = canvas.get_data ();
size_t buffer_size = width * height * 4;
size_t read_size = in.read (buffer, buffer_size);
@@ -109,11 +108,10 @@
{
perr(PINGUS_DEBUG_EDITOR) << "ThumbCache: " << filename << ":
read error: wanted "
<< buffer_size << " got " << read_size
<< std::endl;
- delete canvas;
return uncached_load (res_ident, datafile);
}
- canvas->unlock ();
- return CL_Surface (canvas, true);
+ canvas.unlock ();
+ return CL_Surface (new CL_PixelBuffer(canvas), true);
}
catch (CL_Error& err)
{
Modified: trunk/src/gui/buffer_graphic_context.cxx
===================================================================
--- trunk/src/gui/buffer_graphic_context.cxx 2004-05-06 18:53:10 UTC (rev
2307)
+++ trunk/src/gui/buffer_graphic_context.cxx 2004-05-06 20:57:36 UTC (rev
2308)
@@ -21,17 +21,20 @@
#include <ClanLib/display.h>
#include "../pingus_error.hxx"
#include "../blitter.hxx"
-#include "../canvas.hxx"
#include "../screenshot.hxx"
#include "buffer_graphic_context.hxx"
namespace Pingus {
BufferGraphicContext::BufferGraphicContext(int width, int height)
+ : canvas(width, height, width*4, CL_PixelFormat::rgba8888)
{
- canvas = Canvas::create_rgba8888(width, height);
}
+BufferGraphicContext::~BufferGraphicContext()
+{
+}
+
CL_Rect
BufferGraphicContext::get_clip_rect()
{
@@ -55,14 +58,12 @@
void
BufferGraphicContext::draw (CL_Surface& sur, int x_pos, int y_pos)
{
-#ifdef CLANLIB_0_6
//std::cout << "BufferGraphicContext: " << x_pos << ", " << y_pos <<
std::endl;
try {
- Blitter::put_surface(canvas, sur.get_provider(), x_pos, y_pos);
+ Blitter::put_surface(canvas, sur.get_pixeldata(), x_pos, y_pos);
} catch (PingusError& err) {
std::cout << "BufferGraphicContext: " << err.get_message() << std::endl;
}
-#endif
}
void
@@ -95,12 +96,10 @@
void
BufferGraphicContext::write(const std::string& filename)
{
-#ifdef CLANLIB_0_6
std::cout << "BufferGraphicContext::write: " << filename << std::endl;
- canvas->lock();
+ canvas.lock();
Screenshot::save_target_to_file(canvas, filename);
- canvas->unlock();
-#endif
+ canvas.unlock();
}
} // namespace Pingus
Modified: trunk/src/gui/buffer_graphic_context.hxx
===================================================================
--- trunk/src/gui/buffer_graphic_context.hxx 2004-05-06 18:53:10 UTC (rev
2307)
+++ trunk/src/gui/buffer_graphic_context.hxx 2004-05-06 20:57:36 UTC (rev
2308)
@@ -39,10 +39,11 @@
class BufferGraphicContext : public GraphicContext
{
private:
- CL_PixelBuffer* canvas;
+ CL_PixelBuffer canvas;
public:
BufferGraphicContext(int width, int height);
+ virtual ~BufferGraphicContext();
Vector get_offset () { return Vector(); }
void set_offset (float, float) {}
@@ -52,8 +53,8 @@
float get_x_offset () { return 0; }
float get_y_offset () { return 0; }
- int get_width () { return canvas->get_width(); }
- int get_height () { return canvas->get_height(); }
+ int get_width () { return canvas.get_width(); }
+ int get_height () { return canvas.get_height(); }
float get_zoom () { return 1.0f; }
void set_zoom (float new_zoom) { UNUSED_ARG(new_zoom); }
Modified: trunk/src/pingus_counter.cxx
===================================================================
--- trunk/src/pingus_counter.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/pingus_counter.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -34,7 +34,7 @@
PingusCounter::PingusCounter(Server* s)
: server(s),
- background (PingusResource::load_surface("Buttons/info","core"))
+ background(PingusResource::load_sprite("buttons/info","core"))
{
font = Fonts::pingus_small_fix_num;
}
@@ -45,7 +45,7 @@
char str[128];
if (!fast_mode)
- background.draw (CL_Display::get_width ()/2 - background.get_width()/2, 0);
+ background.draw(CL_Display::get_width()/2, 0);
World* world = server->get_world();
Modified: trunk/src/pingus_counter.hxx
===================================================================
--- trunk/src/pingus_counter.hxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/pingus_counter.hxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -20,7 +20,7 @@
#ifndef HEADER_PINGUS_PINGUS_COUNTER_HXX
#define HEADER_PINGUS_PINGUS_COUNTER_HXX
-#include <ClanLib/Display/surface.h>
+#include <ClanLib/Display/sprite.h>
#include <ClanLib/Display/font.h>
#include "gui/component.hxx"
@@ -37,7 +37,7 @@
private:
Server* server;
CL_Font font;
- CL_Surface background;
+ CL_Sprite background;
public:
PingusCounter(Server* s);
virtual ~PingusCounter() {}
Modified: trunk/src/pingus_resource.cxx
===================================================================
--- trunk/src/pingus_resource.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/pingus_resource.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -238,15 +238,14 @@
CL_Surface
PingusResource::load_from_source (const ResDescriptor& res_desc)
{
- //std::cout << "RESDUMP: " << res_desc << std::endl;
-
switch(res_desc.type)
{
case ResDescriptor::RD_RESOURCE:
try {
CL_ResourceManager res_mgr = get(res_desc.datafile);
- return CL_Surface (res_desc.res_name.c_str(), &res_mgr);
+ return CL_Surface(res_desc.res_name.c_str(), &res_mgr);
} catch (CL_Error err) {
+ pout << "CL_Error: " << err.message << std::endl;
pout << "PingusResource:" << res_desc
<< ":-404-:" << err.message << std::endl;
try {
Modified: trunk/src/screenshot.cxx
===================================================================
--- trunk/src/screenshot.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/screenshot.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -23,6 +23,8 @@
#include <fstream>
#include <iostream>
+#include <ClanLib/Display/pixel_format.h>
+#include <ClanLib/Display/pixel_buffer.h>
#include <ClanLib/Display/display.h>
#include "system.hxx"
#include "screenshot.hxx"
@@ -58,27 +60,26 @@
}
void
-Screenshot::save_target_to_file(CL_Target* target, const std::string& filename)
+Screenshot::save_target_to_file(CL_PixelBuffer target, const std::string&
filename)
{
save_target_to_file_fast(target, filename);
}
void
-Screenshot::save_target_to_file_fast(CL_Target* target, const std::string&
filename)
+Screenshot::save_target_to_file_fast(CL_PixelBuffer target, const std::string&
filename)
{
-#ifdef CLANLIB_0_6
- target->lock();
- int num_pixels = target->get_width() * target->get_height();
+ target.lock();
+ int num_pixels = target.get_width() * target.get_height();
unsigned char* buffer = new unsigned char[num_pixels * 3];
- unsigned char* target_buffer = reinterpret_cast<unsigned
char*>(target->get_data());
+ unsigned char* target_buffer = reinterpret_cast<unsigned
char*>(target.get_data());
- unsigned int rmask = target->get_red_mask();
- unsigned int gmask = target->get_green_mask();
- unsigned int bmask = target->get_blue_mask();
+ unsigned int rmask = target.get_format().get_red_mask();
+ unsigned int gmask = target.get_format().get_green_mask();
+ unsigned int bmask = target.get_format().get_blue_mask();
- switch(target->get_bytes_per_pixel())
+ switch(target.get_format().get_depth())
{
- case 2: // 16bit
+ case 16: // 16bit
{
for (int i = 0; i < num_pixels; ++i)
{
@@ -90,7 +91,7 @@
}
break;
}
- case 3: // 24bit
+ case 24: // 24bit
{
// that should do the trick - untested !!!
for (int i = 0; i < num_pixels; ++i)
@@ -108,7 +109,7 @@
}
break;
}
- case 4: // 32bit
+ case 32: // 32bit
{
for (int i = 0; i < num_pixels; ++i)
{
@@ -121,10 +122,9 @@
}
- target->unlock();
- save_ppm(filename, buffer, target->get_width(), target->get_height());
+ target.unlock();
+ save_ppm(filename, buffer, target.get_width(), target.get_height());
delete[] buffer;
-#endif
}
void
@@ -153,33 +153,30 @@
}
void
-Screenshot::save_target_to_file_slow(CL_Target* target, const std::string&
filename)
+Screenshot::save_target_to_file_slow(CL_PixelBuffer target, const std::string&
filename)
{
-#ifdef CLANLIB_0_6
std::ofstream out(filename.c_str());
out << "P3\n"
<< "# CREATOR: Pingus... some version\n"
- << target->get_width() << " "
- << target->get_height() << "\n"
+ << target.get_width() << " "
+ << target.get_height() << "\n"
<< "255" << std::endl;
- target->lock();
+ target.lock();
- float red, green, blue, alpha;
- for (unsigned int y=0; y < target->get_height(); ++y)
+ for (int y=0; y < target.get_height(); ++y)
{
- for (unsigned int x=0; x < target->get_width(); ++x)
+ for (int x=0; x < target.get_width(); ++x)
{
- target->get_pixel(x, y, &red, &green, &blue, &alpha);
- out << (int)(red * 255) << " "
- << (int)(green * 255) << " "
- << (int)(blue * 255) << "\n";
+ CL_Color color = target.get_pixel(x, y);
+ out << (int)(color.get_red()) << " "
+ << (int)(color.get_green()) << " "
+ << (int)(color.get_blue()) << "\n";
}
}
- target->unlock();
-#endif
+ target.unlock();
}
std::string
Modified: trunk/src/screenshot.hxx
===================================================================
--- trunk/src/screenshot.hxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/screenshot.hxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -21,6 +21,7 @@
#define HEADER_PINGUS_SCREENSHOT_HXX
#include "pingus.hxx"
+#include <ClanLib/Display/pixel_buffer.h>
#include <string>
class CL_Target;
@@ -33,11 +34,11 @@
private:
static std::string get_date();
static std::string get_filename();
- static void save_target_to_file_fast(CL_Target*, const std::string&
filename);
- static void save_target_to_file_slow(CL_Target*, const std::string&
filename);
+ static void save_target_to_file_fast(CL_PixelBuffer , const std::string&
filename);
+ static void save_target_to_file_slow(CL_PixelBuffer , const std::string&
filename);
public:
static std::string make_screenshot();
- static void save_target_to_file(CL_Target*, const std::string& filename);
+ static void save_target_to_file(CL_PixelBuffer , const std::string&
filename);
/** buffer must be RGB and width*height*3 large */
static void save_ppm(const std::string& filename, unsigned char* buffer, int
width, int height);
Modified: trunk/src/smallmap.cxx
===================================================================
--- trunk/src/smallmap.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/smallmap.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -25,7 +25,6 @@
#include "pingus_resource.hxx"
#include "smallmap.hxx"
#include "col_map.hxx"
-#include "canvas.hxx"
#include "true_server.hxx"
#include "pingu.hxx"
#include "math.hxx"
@@ -94,12 +93,12 @@
height = max_height;
}
- canvas = Canvas::create_rgba8888(width, height);
+ canvas = CL_PixelBuffer(width, height, width*4,
CL_PixelFormat::rgba8888);
}
- canvas->lock();
+ canvas.lock();
- cbuffer = static_cast<unsigned char*>(canvas->get_data());
+ cbuffer = static_cast<unsigned char*>(canvas.get_data());
int alpha;
if (fast_mode)
@@ -172,10 +171,10 @@
}
}
}
- canvas->unlock();
+ canvas.unlock();
//Timer surface_timer("Smallmap surface creation");
- sur = CL_Surface(canvas, false);
+ sur = CL_Surface(new CL_PixelBuffer(canvas), true);
//surface_timer.stop();
x_pos = 5;
Modified: trunk/src/smallmap.hxx
===================================================================
--- trunk/src/smallmap.hxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/smallmap.hxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -48,7 +48,7 @@
CL_Surface sur;
/** The canvas that represents the small-colmap */
- CL_PixelBuffer* canvas;
+ CL_PixelBuffer canvas;
/** Horizontal position of the small map */
int x_pos;
Modified: trunk/src/smallmap_image.cxx
===================================================================
--- trunk/src/smallmap_image.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/smallmap_image.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -18,10 +18,10 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <ClanLib/Display/pixel_buffer.h>
+#include <ClanLib/Display/pixel_format.h>
#include "world.hxx"
#include "smallmap_image.hxx"
#include "col_map.hxx"
-#include "canvas.hxx"
#include "server.hxx"
namespace Pingus {
@@ -63,7 +63,7 @@
ColMap* colmap = world->get_colmap();
buffer = colmap->get_data();
- canvas = Canvas::create_rgba8888(width, height);
+ canvas = new CL_PixelBuffer(width, height, width*4,
CL_PixelFormat::rgba8888);
canvas->lock();
Modified: trunk/src/spot_map.cxx
===================================================================
--- trunk/src/spot_map.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/spot_map.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -26,7 +26,6 @@
#include "blitter.hxx"
#include "spot_map.hxx"
#include "gettext.h"
-#include "canvas.hxx"
#include "col_map.hxx"
#include "math.hxx"
@@ -69,7 +68,7 @@
MapTileSurface::reload(void)
{
CL_PixelBuffer buf = surface.get_pixeldata();
- surface = CL_Surface(&buf, false);
+ surface = CL_Surface(new CL_PixelBuffer(buf), true);
}
void
@@ -383,14 +382,14 @@
{
if (tile[ix][iy].surface == 0)
{
- CL_PixelBuffer* canvas = Canvas::create_rgba8888(tile_size,
tile_size);
+ CL_PixelBuffer canvas(tile_size, tile_size, tile_size * 4,
CL_PixelFormat::rgba8888);
- Blitter::clear_canvas(*canvas);
+ Blitter::clear_canvas(canvas);
- Blitter::put_surface(*canvas, sprovider,
+ Blitter::put_surface(canvas, sprovider,
x - (ix * tile_size), y - (iy * tile_size));
- tile[ix][iy].surface = CL_Surface (canvas, true);
+ tile[ix][iy].surface = CL_Surface (new CL_PixelBuffer(canvas),
true);
}
else
{
Modified: trunk/src/world.cxx
===================================================================
--- trunk/src/world.cxx 2004-05-06 18:53:10 UTC (rev 2307)
+++ trunk/src/world.cxx 2004-05-06 20:57:36 UTC (rev 2308)
@@ -134,10 +134,8 @@
for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
{
- std::cout << "drawing: " << typeid(*obj).name() << ": " << *obj <<
std::endl;
(*obj)->draw(gc);
}
- std::cout << "Done" << std::endl;
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] rev 2308 - in trunk: data/data src src/caimagemanipulation src/editor src/gui,
Ingo Ruhnke <=