Page 1 of 1

Surface problem

PostPosted: Apr 24, 2006 @ 4:25pm
by Lexx31337
Hi every1 !
Sorry for my bad english... :) Let's speak in С++ lang :)

i have a problem with creation of a new surface:

1:
Surface * pTexture1 = LoadImage("..."); //first sprite
pTexture1->SetColorMask( Color(0,0,0) ); //setup alpha
//and second sprite:
Surface * pTexture2 = new Surface(100,100);
Rasterizer pRast = Rasterizer(pTexture2);
pRast.Clear(Color(0,0,0));
pRast.Blit( 0, 0, pTexture1 ); // try to copy first image into second
// and now, pTexture2 has no "m_colorMask" from first image... my error?

So... how i can transfer part of image into another inage WITH ALPHA-DATA ?


2: Let's see at Surface.h and Surface.cpp in the PocketFrog (i have v.0.8.1)

// class description:
// Surface.h
class Surface : PHAL::NonCopyable
{
...
private:
...
unsigned m_colorMask; // Source color key
}

//and...
// default constructor of this class:
// Surface.cpp
Surface::Surface( unsigned width, unsigned height )
: m_buffer( PHAL::Surface::Create( width, height ) ),
m_colorMask( -1 ),// is it right? "-1"
m_original( 0 ),
m_hdc( 0 )
{
}


3:
In some part of my engine, i create MANY sprites (something about 3~6 Mb, yeah, i'm crazy, and my Fujitsu (PDA) thinks same... :D ). I have a free memory, but Surface * pSurface = new Surface(512,512) returns pointer with m_buffer=NULL ! Also, sometimes, i can't create sprite with GREAT SIZE (1000x1600). There's a PHAL - limitation? Or it's my errors? I can't use many small sprites instead one big (programm limitation...). Help me plz!

How many mistakes in my english i have? Is it very bad? :)

PostPosted: Apr 24, 2006 @ 7:52pm
by BIGBEN

PostPosted: Apr 25, 2006 @ 5:21am
by Lexx31337
Hi BIGBEN! Spb? :)
so... in my first sprite a have some image(some part of this image has black color, it will be transparent SetColorMask( Color(0,0,0) ). After copy this image to second sprite, i have same image, BUT ! it's has no right value in m_colorMask! In second image a have undefined value (345467676233... something like that), cos in default constructor something wrong ( unsigned m_colorMask = -1 ) and function pRast.Blit( 0, 0, pTexture1 ) does not copy it from first sprite... I try with some colorMask, but it's not work...
I have same problem, when i load 16-bit image (R5G5B5) and try to set colorMask (SetColorMask( Color(...))), after drawing to screen, image has no transparent parts... This problem has gone, when i use 24-bit image...

PostPosted: Apr 25, 2006 @ 11:52am
by BIGBEN

Re: Surface problem

PostPosted: Apr 26, 2006 @ 3:01pm
by BradK3