MCPcopy Create free account
hub / github.com/SpartanJ/eepp / save

Method save

src/eepp/graphics/texturepacker.cpp:610–669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

608}
609
610void TexturePacker::save( const std::string& Filepath, const Image::SaveType& Format,
611 const bool& KeepExtensions ) {
612 if ( !mPacked )
613 packTextures();
614
615 if ( !mTextures.size() )
616 return;
617
618 mFilepath = Filepath;
619 mKeepExtensions = KeepExtensions;
620
621 Image Img( (Uint32)mWidth, (Uint32)mHeight, getAtlasNumChannels() );
622
623 Img.fillWithColor( Color( 0, 0, 0, 0 ) );
624
625 TexturePackerTex* t = NULL;
626 std::vector<TexturePackerTex*>::iterator it;
627
628 for ( it = mTextures.begin(); it != mTextures.end(); ++it ) {
629 t = ( *it );
630
631 if ( t->placed() ) {
632 Uint8* data;
633
634 if ( NULL == t->getImage() ) {
635 Image imageLoaded( t->name() );
636
637 if ( NULL != imageLoaded.getPixelsPtr() &&
638 t->width() == (int)imageLoaded.getWidth() &&
639 t->height() == (int)imageLoaded.getHeight() ) {
640 if ( t->flipped() )
641 imageLoaded.flip();
642
643 Img.copyImage( &imageLoaded, t->x(), t->y() );
644
645 mPlacedCount++;
646 }
647 } else {
648 data = t->getImage()->getPixels();
649
650 if ( NULL != data ) {
651 if ( t->flipped() )
652 t->getImage()->flip();
653
654 Img.copyImage( t->getImage(), t->x(), t->y() );
655
656 mPlacedCount++;
657 }
658 }
659 }
660 }
661
662 mFormat = Format;
663
664 Img.saveToFile( Filepath, Format );
665
666 childSave( Format );
667

Callers 2

updateTextureAtlasMethod · 0.45
childSaveMethod · 0.45

Calls 15

placedMethod · 0.80
getPixelsMethod · 0.80
sizeMethod · 0.45
fillWithColorMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getImageMethod · 0.45
getPixelsPtrMethod · 0.45
widthMethod · 0.45
getWidthMethod · 0.45
heightMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected