home *** CD-ROM | disk | FTP | other *** search
- #include "PictureFormatManagerPtr.h"
- #include "TwinPictureFormat.h"
- #include "AutoPtr.h"
- #include "Color.h"
- #include "ResourceManagerPtr.h"
- #include "Resource.h"
- #include "String.h"
- #include "safe_new.h"
-
- bool TwinPictureFormat::recursion = false;
-
- TwinPictureFormat::TwinPictureFormat(const String & name)
- : data( 0 ),
- sx( 0 ),
- sy( 0 )
- {
- if( recursion )
- return;
- recursion = true; // êºíáó½∩Ѽß∩ «Γ »«»δΓ¬¿ ß«ºñáΓ∞ TwinResource, ß«ßΓ«∩Θ¿⌐ ¿º ñαπú¿σ TwinResource'«ó
- AutoPtr<PictureFormat> cfor = PictureFormatManagerPtr()->create_format( name );
- AutoPtr<PictureFormat> afor = PictureFormatManagerPtr()->create_format( name + "_a" );
- recursion = false;
- if( !cfor || !afor )
- return;
- if( cfor->width() != afor->width() || cfor->height() != afor->height() )
- return;
- sx = cfor->width();
- sy = afor->height();
-
- data = new Color[sx*sy];
-
- const Color * cd = cfor->colors();
- const Color * ad = afor->colors();
- Color * curr = data;
- const Color * data_end = curr + sx*sy;
- for( ; curr != data_end; ++curr, ++cd, ++ad )
- {
- *curr = *cd;
- curr->a = ad->r;
- }
- }
-
- TwinPictureFormat::~TwinPictureFormat()
- {
- delete data; data = 0;
- }
-
- unsigned TwinPictureFormat::width()const
- {
- return sx;
- }
-
- unsigned TwinPictureFormat::height()const
- {
- return sy;
- }
-
- const Color * TwinPictureFormat::colors()const
- {
- return data;
- }
-