|
|
@ -6,21 +6,62 @@ |
|
|
|
#include "Raster.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "Image.h"
|
|
|
|
#include <malloc.h>
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
|
|
|
|
|
gint height = 500; |
|
|
|
gint width = 500; |
|
|
|
gint height = 600; |
|
|
|
gint width = 800; |
|
|
|
|
|
|
|
Raster raster(width, height); |
|
|
|
|
|
|
|
void example1() { |
|
|
|
//画背景
|
|
|
|
Image* image1 = Image::loadFromFile("/home/blobt/Documents/dev/cpp/3dbase/build/bin/image/bg.png"); |
|
|
|
raster.drawImage(0, 0, image1); |
|
|
|
delete image1; |
|
|
|
|
|
|
|
//画前景
|
|
|
|
Image* image2 = Image::loadFromFile("/home/blobt/Documents/dev/cpp/3dbase/build/bin/image/colorKey.bmp"); |
|
|
|
raster.drawImageWithKey(200, 250, image2, Rgba(255, 0, 0)); |
|
|
|
delete image2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void example2() { |
|
|
|
int left = 0; |
|
|
|
int bottom = 0; |
|
|
|
|
|
|
|
int right = 300; |
|
|
|
int top = 100; |
|
|
|
|
|
|
|
Rgba* t = new Rgba[800 * 600]; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 800 * 600; i++) { |
|
|
|
t[i] = Rgba(255, 255, 255); |
|
|
|
} |
|
|
|
|
|
|
|
int ys = 0; |
|
|
|
for (int y = bottom; y < top; y++) { |
|
|
|
ys++; |
|
|
|
for (int x = left; x < right; x++) { |
|
|
|
//raster.setPixel(x, y, Rgba(255, 0, 0));
|
|
|
|
t[(height - ys) * width + x] = Rgba(255, 0, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
memcpy(raster.buffer, t, 800 * 600 * 4); |
|
|
|
|
|
|
|
|
|
|
|
delete t; |
|
|
|
} |
|
|
|
|
|
|
|
unsigned char* makeBitmap() { |
|
|
|
raster.clean(); |
|
|
|
|
|
|
|
Image* image = Image::loadFromFile("/home/blobt/Documents/dev/cpp/3dbase/build/bin/12.jpg"); |
|
|
|
|
|
|
|
raster.drawImage(25, 25, image); |
|
|
|
example1(); |
|
|
|
|
|
|
|
return (unsigned char*) raster.buffer; |
|
|
|
} |
|
|
|