Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / ksplash / ksplashx / utils / prepareanim.cpp
bloba117c700bcd3d1d52f37358315a6702c3e351a50
1 // This tool creates png image with animation (see README)
3 #include <QFile>
4 #include <QImage>
6 #include <stdlib.h>
7 #include <kdebug.h>
8 #include <stdio.h>
10 const int ANIM_IMAGES_ROW = 10; // must match splash
12 int main( int argc, char* argv[] )
14 // <list of images in order>
15 if( argc < 2 )
16 return 1;
17 const int ARGC_DIFF = 1;
18 int frames = argc - ARGC_DIFF;
19 QImage result;
20 for( int frame = 0;
21 frame < frames;
22 ++frame )
24 QImage fr( argv[ ARGC_DIFF + frame ] );
25 if( fr.isNull())
26 return 2;
27 int w = fr.width();
28 int h = fr.height();
29 if( result.isNull())
30 { // initialize
31 if( frames < ANIM_IMAGES_ROW )
32 result = QImage( frames * w, h, QImage::Format_ARGB32 );
33 else
34 result = QImage( ANIM_IMAGES_ROW * w, ( frames + ANIM_IMAGES_ROW - 1 ) / ANIM_IMAGES_ROW * h, QImage::Format_ARGB32 );
36 int basex = ( frame % ANIM_IMAGES_ROW ) * w;
37 int basey = frame / ANIM_IMAGES_ROW * h;
38 for( int y = 0;
39 y < h;
40 ++y )
41 for( int x = 0;
42 x < w;
43 ++x )
44 result.setPixel( basex + x, basey + y, fr.pixel( x, y ));
46 result.save( "result.png", "PNG" );