~ubuntu-branches/ubuntu/karmic/photoprint/karmic

« back to all changes in this revision

Viewing changes to imagesource/imagesource_solid.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Milan Zamazal
  • Date: 2007-05-01 16:32:13 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20070501163213-k0gaendx7grjlmk5
Tags: upstream-0.3.5
ImportĀ upstreamĀ versionĀ 0.3.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * imagesource_solid.cpp
 
3
 *
 
4
 * Supports Greyscale, RGB and CMYK data
 
5
 * Supports random access
 
6
 *
 
7
 * Copyright (c) 2004 by Alastair M. Robinson
 
8
 * Distributed under the terms of the GNU General Public License -
 
9
 * see the file named "COPYING" for more details.
 
10
 *
 
11
 */
 
12
 
 
13
#include <iostream>
 
14
#include <stdlib.h>
 
15
#include <string.h>
 
16
#include <math.h>
 
17
 
 
18
#include "imagesource_solid.h"
 
19
 
 
20
using namespace std;
 
21
 
 
22
ImageSource_Solid::~ImageSource_Solid()
 
23
{
 
24
}
 
25
 
 
26
 
 
27
ISDataType *ImageSource_Solid::GetRow(int row)
 
28
{
 
29
        int i;
 
30
 
 
31
        if(row==currentrow)
 
32
                return(rowbuffer);
 
33
 
 
34
        for(int x=0;x<width;++x)
 
35
        {
 
36
                for(i=0;i<samplesperpixel;++i)
 
37
                {
 
38
                        rowbuffer[x*samplesperpixel+i]=solid[i];
 
39
                }
 
40
        }
 
41
        currentrow=row;
 
42
 
 
43
        return(rowbuffer);
 
44
}
 
45
 
 
46
 
 
47
ImageSource_Solid::ImageSource_Solid(IS_TYPE type,int width,int height,ISDataType *sld)
 
48
        : ImageSource()
 
49
{
 
50
        this->width=width;
 
51
        this->height=height;
 
52
        this->type=type;
 
53
 
 
54
        switch(type)
 
55
        {
 
56
                case IS_TYPE_GREY:
 
57
                        samplesperpixel=1;
 
58
                        break;
 
59
                case IS_TYPE_RGB:
 
60
                        samplesperpixel=3;
 
61
                        break;
 
62
                case IS_TYPE_CMYK:
 
63
                        samplesperpixel=4;
 
64
                        break;
 
65
                case IS_TYPE_GREYA:
 
66
                        samplesperpixel=2;
 
67
                        break;
 
68
                case IS_TYPE_RGBA:
 
69
                        samplesperpixel=4;
 
70
                        break;
 
71
                case IS_TYPE_CMYKA:
 
72
                        samplesperpixel=5;
 
73
                        break;
 
74
                default:
 
75
                        throw "Solid: Type not supported.";
 
76
        }
 
77
        if(sld)
 
78
        {
 
79
                for(int i=0;i<samplesperpixel;++i)
 
80
                {
 
81
                        solid[i]=sld[i];
 
82
                }
 
83
        }
 
84
        else
 
85
        {
 
86
                for(int i=0;i<samplesperpixel;++i)
 
87
                {
 
88
                        solid[i]=0;
 
89
                }
 
90
        }       
 
91
        MakeRowBuffer();
 
92
}