|
@@ -0,0 +1,317 @@
|
|
|
|
+#include <main.h>
|
|
|
|
+#include <Fenster.h>
|
|
|
|
+#include <Bildschirm.h>
|
|
|
|
+#include <RenderThread.h>
|
|
|
|
+#include <DateiSystem.h>
|
|
|
|
+#include <Schrift.h>
|
|
|
|
+#include <Knopf.h>
|
|
|
|
+#include <DateiDialog.h>
|
|
|
|
+#include <Bild.h>
|
|
|
|
+#include <Datei.h>
|
|
|
|
+#include <AsynchronCall.h>
|
|
|
|
+#include <Fortschritt.h>
|
|
|
|
+
|
|
|
|
+using namespace Framework;
|
|
|
|
+
|
|
|
|
+Framework::Knopf *initKnopf( int x, int y, int width, int height, int style, const char *txt, Framework::Schrift *zSchrift )
|
|
|
|
+{
|
|
|
|
+ Framework::Knopf *ret = new Framework::Knopf();
|
|
|
|
+ ret->setPosition( x, y );
|
|
|
|
+ ret->setSize( width, height );
|
|
|
|
+ ret->setText( txt );
|
|
|
|
+ ret->setStyle( style );
|
|
|
|
+ ret->setMausEreignis( Framework::_ret1ME );
|
|
|
|
+ ret->setSchriftZ( zSchrift->getThis() );
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TextFeld *initTextFeld( int x, int y, int br, int hö, Schrift *zSchrift, __int64 style, char *txt )
|
|
|
|
+{
|
|
|
|
+ TextFeld *ret = new TextFeld();
|
|
|
|
+ ret->setStyle( style );
|
|
|
|
+ ret->setSchriftZ( zSchrift->getThis() );
|
|
|
|
+ ret->setText( txt );
|
|
|
|
+ ret->setSchriftFarbe( 0xFFFFFFFF );
|
|
|
|
+ ret->setSchriftSize( 12 );
|
|
|
|
+ if( ret->hatStyle( TextFeld::Style::Buffered ) )
|
|
|
|
+ {
|
|
|
|
+ ret->setAlphaFeldFarbe( 0x5500FF00 );
|
|
|
|
+ ret->setAlphaFeldStrength( -5 );
|
|
|
|
+ }
|
|
|
|
+ if( ret->hatStyle( TextFeld::Style::Rahmen ) )
|
|
|
|
+ {
|
|
|
|
+ ret->setLinienRahmenBreite( 1 );
|
|
|
|
+ ret->setLinienRahmenFarbe( 0xFF00FF00 );
|
|
|
|
+ }
|
|
|
|
+ ret->setPosition( x, y );
|
|
|
|
+ ret->setSize( br, hö );
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+FBalken *initFortschritt( int x, int y, int width, int height, Schrift *zSchrift )
|
|
|
|
+{
|
|
|
|
+ FBalken *ret = new FBalken();
|
|
|
|
+ ret->setStyle( FBalken::Style::Sichtbar | FBalken::Style::Prozent | FBalken::Style::Rahmen | FBalken::Style::Hintergrund | FBalken::Style::FFarbe | FBalken::Style::L_R );
|
|
|
|
+ ret->setLinienRahmenFarbe( 0xFFFFFFFF );
|
|
|
|
+ ret->setHintergrundFarbe( 0xFF005000 );
|
|
|
|
+ ret->setFBgFarbe( 0xFF00FF00 );
|
|
|
|
+ ret->setAktionAnzahl( 100 );
|
|
|
|
+ ret->setSchriftZ( zSchrift->getThis() );
|
|
|
|
+ ret->setSFarbe( 0xFFFFFFFF );
|
|
|
|
+ ret->setSSize( 12 );
|
|
|
|
+ ret->setSize( width, height );
|
|
|
|
+ ret->setPosition( x, y );
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+BildZ *initBild( int x, int y, int width, int height )
|
|
|
|
+{
|
|
|
|
+ BildZ *ret = new BildZ();
|
|
|
|
+ ret->setStyle( BildZ::Style::Sichtbar | BildZ::Style::Alpha );
|
|
|
|
+ ret->setPosition( x, y );
|
|
|
|
+ ret->setSize( width, height );
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TextFeld *_path;
|
|
|
|
+TextFeld *_start;
|
|
|
|
+TextFeld *_end;
|
|
|
|
+TextFeld *_width;
|
|
|
|
+TextFeld *_height;
|
|
|
|
+TextFeld *_targetWidth;
|
|
|
|
+TextFeld *_targetHeight;
|
|
|
|
+TextFeld *_transparent;
|
|
|
|
+TextFeld *_output;
|
|
|
|
+Knopf *_render;
|
|
|
|
+FBalken *_gesamtF;
|
|
|
|
+BildZ *_source;
|
|
|
|
+BildZ *_rendered;
|
|
|
|
+
|
|
|
|
+void setPath( Text *path )
|
|
|
|
+{
|
|
|
|
+ Text err;
|
|
|
|
+ Bild *img = Framework::ladeBild( path->getText(), &err );
|
|
|
|
+ if( !img )
|
|
|
|
+ {
|
|
|
|
+ path->release();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ path->ersetzen( "\\", "/" );
|
|
|
|
+ Text *p = path->getTeilText( 0, path->positionVon( "/", path->anzahlVon( "/" ) - 1 ) );
|
|
|
|
+
|
|
|
|
+ Datei d;
|
|
|
|
+ d.setDatei( p->getText() );
|
|
|
|
+ RCArray< Text > *list = d.getDateiListe();
|
|
|
|
+
|
|
|
|
+ p->insert( 0, "Pfad: " );
|
|
|
|
+ _path->setText( p );
|
|
|
|
+ _start->setText( path->getTeilText( path->positionVon( "/", path->anzahlVon( "/" ) - 1 ) + 1 ) );
|
|
|
|
+ _end->setText( list->get( list->getEintragAnzahl() - 1 ) );
|
|
|
|
+ _width->setText( Text( "Breite: " ) += img->getBreite() );
|
|
|
|
+ _height->setText( Text( "Höhe: " ) += img->getHeight() );
|
|
|
|
+ _targetWidth->setText( Text( img->getBreite() ) );
|
|
|
|
+ _targetHeight->setText( Text( img->getHeight() ) );
|
|
|
|
+
|
|
|
|
+ list->release();
|
|
|
|
+ img->release();
|
|
|
|
+ path->release();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void renderF()
|
|
|
|
+{
|
|
|
|
+ Text *type = _start->zText()->getTeilText( _start->zText()->positionVon( "." ) );
|
|
|
|
+ int length = _start->zText()->getLength() - type->getLength();
|
|
|
|
+ int startId = *_start->zText();
|
|
|
|
+ int endId = *_end->zText();
|
|
|
|
+ _gesamtF->setAktionAnzahl( endId - startId );
|
|
|
|
+ _gesamtF->reset();
|
|
|
|
+ LTDBDatei d;
|
|
|
|
+ d.setDatei( _output->getText() );
|
|
|
|
+ d.remove();
|
|
|
|
+ d.erstellen();
|
|
|
|
+ int bnLength = 0;
|
|
|
|
+ for( int i = endId - startId; i > 0; i /= 26, bnLength++ );
|
|
|
|
+ int bnIndex = 0;
|
|
|
|
+ for( int i = startId; i <= endId; i++ )
|
|
|
|
+ {
|
|
|
|
+ Text fileName = i;
|
|
|
|
+ while( fileName.getLength() < length )
|
|
|
|
+ fileName.insert( 0, "0" );
|
|
|
|
+ fileName.append( type->getText() );
|
|
|
|
+ fileName.insert( 0, "/" );
|
|
|
|
+ fileName.insert( 0, _path->zText()->getTeilText( 6 ) );
|
|
|
|
+ Text err;
|
|
|
|
+ Bild *source = ladeBild( fileName, &err );
|
|
|
|
+ if( source )
|
|
|
|
+ {
|
|
|
|
+ int alpfaCol = TextZuInt( *_transparent->zText(), 16 );
|
|
|
|
+ _source->setBildZ( source );
|
|
|
|
+ Bild *rendered = new Bild();
|
|
|
|
+ rendered->neuBild( *_targetWidth->zText(), *_targetHeight->zText(), 0 );
|
|
|
|
+ rendered->drawBildSkall( 0, 0, rendered->getBreite(), rendered->getHeight(), *source );
|
|
|
|
+ rendered->replaceColorWithAlpha( alpfaCol );
|
|
|
|
+ _rendered->setBildZ( rendered->getThis() );
|
|
|
|
+ Text bildName;
|
|
|
|
+ for( int j = 0, tmp = bnIndex; j < bnLength; j++ )
|
|
|
|
+ {
|
|
|
|
+ bildName.insert( 0, 'a' + ( tmp % 26 ) );
|
|
|
|
+ tmp /= 26;
|
|
|
|
+ }
|
|
|
|
+ if( d.speichern( 0, rendered, bildName.getThis() ) >= 0 )
|
|
|
|
+ bnIndex++;
|
|
|
|
+ }
|
|
|
|
+ _gesamtF->aktionPlus();
|
|
|
|
+ }
|
|
|
|
+ _source->setBildZ( 0 );
|
|
|
|
+ type->release();
|
|
|
|
+ _start->addStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _end->addStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _targetWidth->addStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _targetHeight->addStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _transparent->addStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _output->addStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _render->addStyle( Knopf::Style::Erlaubt );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int Framework::Start( Framework::Startparam p )
|
|
|
|
+{
|
|
|
|
+ auto fc = Framework::F_Normal( p.hinst );
|
|
|
|
+ fc.lpszClassName = "Animation Creator";
|
|
|
|
+ fc.lpszMenuName = "Animation Creator";
|
|
|
|
+ WFenster *f = new WFenster();
|
|
|
|
+ f->erstellen( WS_OVERLAPPEDWINDOW, fc );
|
|
|
|
+ f->setNSchließAktion( []( void *p, void *f )
|
|
|
|
+ {
|
|
|
|
+ Framework::StopNachrichtenSchleife( ( (WFenster*)f )->getFensterHandle() );
|
|
|
|
+ } );
|
|
|
|
+ f->setSize( 900, 900 );
|
|
|
|
+ f->setPosition( Punkt( 100, 100 ) );
|
|
|
|
+ f->setMausAktion( _ret1ME );
|
|
|
|
+ f->setTastaturAktion( _ret1TE );
|
|
|
|
+ f->setAnzeigeModus( SW_SHOW );
|
|
|
|
+
|
|
|
|
+ Bildschirm3D *screen = new Bildschirm3D( f->getThis() );
|
|
|
|
+ f->setBildschirm( screen->getThis() );
|
|
|
|
+ screen->update();
|
|
|
|
+
|
|
|
|
+ RenderTh *renderer = new RenderTh();
|
|
|
|
+ renderer->setBildschirm( screen->getThis() );
|
|
|
|
+ renderer->beginn();
|
|
|
|
+
|
|
|
|
+ LTDSDatei *sd = new LTDSDatei();
|
|
|
|
+ sd->setPfad( new Text( "../Data/normal.ltds" ) );
|
|
|
|
+ sd->leseDaten();
|
|
|
|
+ Schrift *schrift = sd->ladeSchrift();
|
|
|
|
+ sd->release();
|
|
|
|
+
|
|
|
|
+ Knopf *k = initKnopf( 10, 10, 100, 20, Knopf::Style::Normal, "Öffnen", schrift );
|
|
|
|
+ k->setMausEreignis( []( void *p, void *o, MausEreignis me )
|
|
|
|
+ {
|
|
|
|
+ if( me.id == ME_RLinks )
|
|
|
|
+ {
|
|
|
|
+ DateiDialog *t = new DateiDialog();
|
|
|
|
+ t->addDateiTyp( "Alle", "*.jpg;*.png;*.bmp" );
|
|
|
|
+ t->addDateiTyp( "Bild", "*.jpg" );
|
|
|
|
+ t->addDateiTyp( "Bild", "*.png" );
|
|
|
|
+ t->addDateiTyp( "Bild", "*.bmp" );
|
|
|
|
+ Text *path = t->anzeigen( 1 );
|
|
|
|
+ t->release();
|
|
|
|
+ if( path )
|
|
|
|
+ setPath( path );
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ _path = initTextFeld( 120, 10, 800, 20, schrift, TextFeld::Style::Text, "Pfad: " );
|
|
|
|
+ TextFeld *startT = initTextFeld( 10, 40, 80, 20, schrift, TextFeld::Style::Text, "Start Bild:" );
|
|
|
|
+ _start = initTextFeld( 90, 40, 100, 20, schrift, TextFeld::Style::TextFeld, "" );
|
|
|
|
+ TextFeld *endT = initTextFeld( 10, 70, 80, 20, schrift, TextFeld::Style::Text, "End Bild:" );
|
|
|
|
+ _end = initTextFeld( 90, 70, 100, 20, schrift, TextFeld::Style::TextFeld, "" );
|
|
|
|
+ _width = initTextFeld( 220, 40, 110, 20, schrift, TextFeld::Style::Text, "Breite:" );
|
|
|
|
+ _height = initTextFeld( 220, 70, 110, 20, schrift, TextFeld::Style::Text, "Höhe:" );
|
|
|
|
+ TextFeld *targetWidthT = initTextFeld( 360, 40, 80, 20, schrift, TextFeld::Style::Text, "Ziel Breite:" );
|
|
|
|
+ _targetWidth = initTextFeld( 440, 40, 60, 20, schrift, TextFeld::Style::TextFeld, "" );
|
|
|
|
+ _targetWidth->setTastaturEreignis( _nurNummernTE );
|
|
|
|
+ TextFeld *targetHeightT = initTextFeld( 360, 70, 80, 20, schrift, TextFeld::Style::Text, "Ziel Höhe:" );
|
|
|
|
+ _targetHeight = initTextFeld( 440, 70, 60, 20, schrift, TextFeld::Style::TextFeld, "" );
|
|
|
|
+ _targetHeight->setTastaturEreignis( _nurNummernTE );
|
|
|
|
+ TextFeld *transparentT = initTextFeld( 530, 40, 120, 20, schrift, TextFeld::Style::Text, "Transparente Farbe:" );
|
|
|
|
+ _transparent = initTextFeld( 650, 40, 80, 20, schrift, TextFeld::Style::TextFeld, "000000" );
|
|
|
|
+ _transparent->setTastaturEreignis( _nurHexTE );
|
|
|
|
+ TextFeld *outputT = initTextFeld( 530, 70, 120, 20, schrift, TextFeld::Style::Text, "Ausgabe Datei:" );
|
|
|
|
+ _output = initTextFeld( 650, 70, 150, 20, schrift, TextFeld::Style::TextFeld, "annimation.ltdb" );
|
|
|
|
+ _gesamtF = initFortschritt( 10, 100, 880, 30, schrift );
|
|
|
|
+ _source = initBild( 30, 150, 400, 400 );
|
|
|
|
+ _rendered = initBild( 470, 150, 400, 400 );
|
|
|
|
+
|
|
|
|
+ _render = initKnopf( 760, 40, 100, 20, Knopf::Style::Normal, "Render", schrift );
|
|
|
|
+ _render->setMausEreignis( []( void *p, void *o, MausEreignis me )
|
|
|
|
+ {
|
|
|
|
+ if( me.id == ME_RLinks )
|
|
|
|
+ {
|
|
|
|
+ _start->removeStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _end->removeStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _targetWidth->removeStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _targetHeight->removeStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _transparent->removeStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _output->removeStyle( TextFeld::Style::Erlaubt );
|
|
|
|
+ _render->removeStyle( Knopf::Style::Erlaubt );
|
|
|
|
+ new AsynchronCall( renderF );
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ screen->addMember( k );
|
|
|
|
+ screen->addMember( _path );
|
|
|
|
+ screen->addMember( startT );
|
|
|
|
+ screen->addMember( _start );
|
|
|
|
+ screen->addMember( endT );
|
|
|
|
+ screen->addMember( _end );
|
|
|
|
+ screen->addMember( _width );
|
|
|
|
+ screen->addMember( _height );
|
|
|
|
+ screen->addMember( targetWidthT );
|
|
|
|
+ screen->addMember( _targetWidth );
|
|
|
|
+ screen->addMember( targetHeightT );
|
|
|
|
+ screen->addMember( _targetHeight );
|
|
|
|
+ screen->addMember( transparentT );
|
|
|
|
+ screen->addMember( _transparent );
|
|
|
|
+ screen->addMember( outputT );
|
|
|
|
+ screen->addMember( _output );
|
|
|
|
+ screen->addMember( _render );
|
|
|
|
+ screen->addMember( _gesamtF );
|
|
|
|
+ screen->addMember( _source );
|
|
|
|
+ screen->addMember( _rendered );
|
|
|
|
+
|
|
|
|
+ Framework::StartNachrichtenSchleife();
|
|
|
|
+
|
|
|
|
+ renderer->beenden();
|
|
|
|
+
|
|
|
|
+ k->release();
|
|
|
|
+ _path->release();
|
|
|
|
+ startT->release();
|
|
|
|
+ _start->release();
|
|
|
|
+ endT->release();
|
|
|
|
+ _end->release();
|
|
|
|
+ _width->release();
|
|
|
|
+ _height->release();
|
|
|
|
+ targetWidthT->release();
|
|
|
|
+ _targetWidth->release();
|
|
|
|
+ targetHeightT->release();
|
|
|
|
+ _targetHeight->release();
|
|
|
|
+ transparentT->release();
|
|
|
|
+ _transparent->release();
|
|
|
|
+ schrift->release();
|
|
|
|
+ outputT->release();
|
|
|
|
+ _output->release();
|
|
|
|
+ _render->release();
|
|
|
|
+ _gesamtF->release();
|
|
|
|
+ _source->release();
|
|
|
|
+ _rendered->release();
|
|
|
|
+
|
|
|
|
+ renderer->release();
|
|
|
|
+ f->setBildschirm( 0 );
|
|
|
|
+ f->release();
|
|
|
|
+ screen->release();
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|