source: trunk/Lucide/SOURCE/plugins/ludoc/lupixbuf.cpp @ 171

Last change on this file since 171 was 171, checked in by Eugene Romanenko, 15 years ago

to rediuce size of spool data: reduce number of colors when multiple pages printed as image

File size: 4.8 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Initial Developer of the Original Code is
15 * Eugene Romanenko, netlabs.org.
16 * Portions created by the Initial Developer are Copyright (C) 2006
17 * the Initial Developer. All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * Alternatively, the contents of this file may be used under the terms of
22 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
23 * in which case the provisions of the LGPL are applicable instead of those
24 * above. If you wish to allow use of your version of this file only under the
25 * terms of the LGPL, and not to allow others to use your version of this file
26 * under the terms of the CDDL, indicate your decision by deleting the
27 * provisions above and replace them with the notice and other provisions
28 * required by the LGPL. If you do not delete the provisions above, a recipient
29 * may use your version of this file under the terms of any one of the CDDL
30 * or the LGPL.
31 *
32 * ***** END LICENSE BLOCK ***** */
33
34
35
36/*
37 *  This file was generated by the SOM Compiler.
38 *  Generated using:
39 *     SOM incremental update: 2.24
40 */
41
42
43/*
44 *  This file was generated by the SOM Compiler and Emitter Framework.
45 *  Generated using template emitter:
46 *      SOM Emitter emitxtm: 2.23.1.9
47 */
48
49#ifndef SOM_Module_lupixbuf_Source
50#define SOM_Module_lupixbuf_Source
51#endif
52#define LuPixbuf_Class_Source
53
54#include "lupixbuf.xih"
55
56
57SOM_Scope void SOMLINK LuPixbufInit(LuPixbuf *somSelf,  Environment *ev, 
58                                    somInitCtrl* ctrl, long w, 
59                                    long h, short bpp)
60{
61    LuPixbufData *somThis;
62    somInitCtrl globalCtrl;
63    somBooleanVector myMask;
64    LuPixbuf_BeginInitializer_LuPixbufInit;
65    LuPixbuf_Init_SOMObject_somDefaultInit(somSelf, ctrl);
66
67    // local LuPixbuf initialization code
68    somThis->width = w;
69    somThis->height = h;
70    somThis->bpp = bpp;
71    somThis->rowsize = ( somThis->width * somThis->bpp );
72    if ( bpp != 4 ) {
73            somThis->rowsize = (somThis->rowsize + 3) &~3;
74        }
75    somThis->dlen = somThis->rowsize * somThis->height;
76    somThis->data = (char *)SOMMalloc( somThis->dlen );
77    memset( somThis->data, 0xff, somThis->dlen );
78}
79
80
81SOM_Scope long  SOMLINK getWidth(LuPixbuf *somSelf,  Environment *ev)
82{
83    LuPixbufData *somThis = LuPixbufGetData(somSelf);
84    return somThis->width;
85}
86
87SOM_Scope long  SOMLINK getHeight(LuPixbuf *somSelf,  Environment *ev)
88{
89    LuPixbufData *somThis = LuPixbufGetData(somSelf);
90    return somThis->height;
91}
92
93SOM_Scope short  SOMLINK getBpp(LuPixbuf *somSelf,  Environment *ev)
94{
95    LuPixbufData *somThis = LuPixbufGetData(somSelf);
96    return somThis->bpp;
97}
98
99SOM_Scope long  SOMLINK getRowSize(LuPixbuf *somSelf,  Environment *ev)
100{
101    LuPixbufData *somThis = LuPixbufGetData(somSelf);
102    return somThis->rowsize;
103}
104
105SOM_Scope long  SOMLINK getDataLen(LuPixbuf *somSelf,  Environment *ev)
106{
107    LuPixbufData *somThis = LuPixbufGetData(somSelf);
108    return somThis->dlen;
109}
110
111SOM_Scope void*  SOMLINK getDataPtr(LuPixbuf *somSelf,  Environment *ev)
112{
113    LuPixbufData *somThis = LuPixbufGetData(somSelf);
114    return somThis->data;
115}
116
117SOM_Scope void  SOMLINK putAt(LuPixbuf *somSelf,  Environment *ev,
118                              LuPixbuf* p, long x, long y)
119{
120    LuPixbufData *somThis = LuPixbufGetData(somSelf);
121    int xlen = __min( somThis->width - x, p->getWidth( ev ) ) * somThis->bpp;
122    int ylen = __min( somThis->height - y, p->getHeight( ev ) );
123    int rowstribe = p->getRowSize( ev );
124    char *fromdt = (char *)p->getDataPtr( ev );
125    char *todt = (char *)somThis->data + ( somThis->rowsize * y );
126    for ( int i = 0; i < ylen; i++ )
127    {
128        char *from = fromdt + ( i * rowstribe );
129        char *to = todt + ( i * somThis->rowsize ) + ( x * somThis->bpp );
130        memcpy( to, from, xlen );
131    }
132}
133
134SOM_Scope void SOMLINK somDestruct(LuPixbuf *somSelf, octet doFree,
135                                   som3DestructCtrl* ctrl)
136{
137    LuPixbufData *somThis;
138    somDestructCtrl globalCtrl;
139    somBooleanVector myMask;
140    LuPixbuf_BeginDestructor;
141
142    // local LuPixbuf deinitialization code
143    SOMFree( somThis->data );
144    // local LuPixbuf deinitialization code end
145
146    LuPixbuf_EndDestructor;
147}
148
149
Note: See TracBrowser for help on using the repository browser.