~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to ksplash/ksplashx/utils/prepareanim.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This tool creates png image with animation (see README)
 
2
 
 
3
#include <QFile>
 
4
#include <QImage>
 
5
 
 
6
#include <stdlib.h>
 
7
#include <kdebug.h>
 
8
#include <stdio.h>
 
9
 
 
10
const int ANIM_IMAGES_ROW = 10; // must match splash
 
11
 
 
12
int main( int argc, char* argv[] )
 
13
    {
 
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 )
 
23
        {
 
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 );
 
35
            }
 
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 ));
 
45
        }
 
46
    result.save( "result.png", "PNG" );
 
47
    }