#pragma once #include #include #include #include #include #include #include #include #include #pragma comment( lib, "gdiplus.lib" ) using namespace Framework; Bild *ladeBild( Text *zPfad ) { Text *txt = zPfad->getTeilText( zPfad->positionVon( '.', zPfad->anzahlVon( '.' ) - 1 ) ); if( !( txt->istGleich( ".bmp" ) || txt->istGleich( ".jpg" ) || txt->istGleich( ".gif" ) || txt->istGleich( ".png" ) ) ) { WMessageBox( 0, new Text( "Error" ), new Text( "Die Angegebene Datei ist keine gueltige Bilddatei!" ), MB_ICONERROR ); txt->release(); return 0; } txt->release(); wchar_t *name = new wchar_t[ zPfad->getLength() + 1 ]; #pragma warning(push) #pragma warning(disable: 4996) mbstowcs( name, zPfad->getText(), zPfad->getLength() ); #pragma warning(pop) name[ zPfad->getLength() ] = '\0'; Gdiplus::Bitmap bitmap( name ); Gdiplus::Color pix; delete[]name; Bild *ret = new Bild(); ret->neuBild( bitmap.GetWidth(), bitmap.GetHeight(), 0 ); int *buff = ret->getBuffer(); for( unsigned int i = 0; i < bitmap.GetWidth() * bitmap.GetHeight(); i++ ) { bitmap.GetPixel( i % bitmap.GetWidth(), i / bitmap.GetWidth(), &pix ); buff[ i ] = pix.GetValue(); } return ret; } int countVerzeichnis( Text *pfad ) { int ret = 0; WIN32_FIND_DATA FData; pfad->ersetzen( '/', '\\' ); if( pfad->positionVon( '\\', pfad->anzahlVon( '\\' ) - 1 ) != pfad->getLength() - 1 ) pfad->append( "\\" ); pfad->append( "*" ); HANDLE hSearch = FindFirstFile( pfad->getText(), &FData ); pfad->remove( pfad->getLength() - 1 ); BOOL MoreFiles = FALSE; int cnt_dir = 0, cnt_file = 0; if( hSearch == INVALID_HANDLE_VALUE ) return 0; do { Text *txt = new Text( FData.cFileName ); if( FData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY ) { if( !( txt->istGleich( ".." ) || txt->istGleich( "." ) ) ) { txt->insert( 0, pfad->getText() ); ret += countVerzeichnis( txt->getThis() ); } } else { txt->insert( 0, pfad->getText() ); Text *end = txt->getTeilText( txt->positionVon( '.', txt->anzahlVon( '.' ) - 1 ) ); if( end->istGleich( ".bmp" ) || end->istGleich( ".jpg" ) || end->istGleich( ".gif" ) || end->istGleich( ".png" ) ) ret++; end->release(); } txt->release(); MoreFiles = FindNextFile( hSearch, &FData ); } while( MoreFiles ); FindClose( hSearch ); pfad->release(); return ret; } void ladeVerzeichnis( Text *pfad, Schrift *zSchrift, LTDBDatei *zDatei, FBalken *fb1, FBalken *fb2 ) { WIN32_FIND_DATA FData; pfad->ersetzen( '/', '\\' ); if( pfad->positionVon( '\\', pfad->anzahlVon( '\\' ) - 1 ) != pfad->getLength() - 1 ) pfad->append( "\\" ); pfad->append( "*" ); HANDLE hSearch = FindFirstFile( pfad->getText(), &FData ); pfad->remove( pfad->getLength() - 1 ); BOOL MoreFiles = FALSE; int cnt_dir = 0, cnt_file = 0; if( hSearch == INVALID_HANDLE_VALUE ) return; do { Text *txt = new Text( FData.cFileName ); if( FData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY ) { if( !( txt->istGleich( ".." ) || txt->istGleich( "." ) ) ) { txt->insert( 0, pfad->getText() ); ladeVerzeichnis( txt->getThis(), zSchrift, zDatei, fb1, fb2 ); } } else { txt->insert( 0, pfad->getText() ); Text *end = txt->getTeilText( txt->positionVon( '.', txt->anzahlVon( '.' ) - 1 ) ); if( end->istGleich( ".bmp" ) || end->istGleich( ".jpg" ) || end->istGleich( ".gif" ) || end->istGleich( ".png" ) ) { zDatei->speichern( fb1, ladeBild( txt ), txt->getTeilText( txt->positionVon( '\\', txt->anzahlVon( '\\' ) - 1 ) + 1 ) ); fb2->aktionPlus(); } end->release(); } txt->release(); MoreFiles = FindNextFile( hSearch, &FData ); } while( MoreFiles ); FindClose( hSearch ); pfad->release(); }