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

Last change on this file since 221 was 221, checked in by Eugene Romanenko, 14 years ago

improve JPEG plugin

File size: 4.9 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    //somPrintf( "LuPixbufInit: allocating %d bytes\n", somThis->dlen );
77    somThis->data = (char *)SOMMalloc( somThis->dlen );
78    memset( somThis->data, 0xff, somThis->dlen );
79}
80
81
82SOM_Scope long  SOMLINK getWidth(LuPixbuf *somSelf,  Environment *ev)
83{
84    LuPixbufData *somThis = LuPixbufGetData(somSelf);
85    return somThis->width;
86}
87
88SOM_Scope long  SOMLINK getHeight(LuPixbuf *somSelf,  Environment *ev)
89{
90    LuPixbufData *somThis = LuPixbufGetData(somSelf);
91    return somThis->height;
92}
93
94SOM_Scope short  SOMLINK getBpp(LuPixbuf *somSelf,  Environment *ev)
95{
96    LuPixbufData *somThis = LuPixbufGetData(somSelf);
97    return somThis->bpp;
98}
99
100SOM_Scope long  SOMLINK getRowSize(LuPixbuf *somSelf,  Environment *ev)
101{
102    LuPixbufData *somThis = LuPixbufGetData(somSelf);
103    return somThis->rowsize;
104}
105
106SOM_Scope long  SOMLINK getDataLen(LuPixbuf *somSelf,  Environment *ev)
107{
108    LuPixbufData *somThis = LuPixbufGetData(somSelf);
109    return somThis->dlen;
110}
111
112SOM_Scope void*  SOMLINK getDataPtr(LuPixbuf *somSelf,  Environment *ev)
113{
114    LuPixbufData *somThis = LuPixbufGetData(somSelf);
115    return somThis->data;
116}
117
118SOM_Scope void  SOMLINK putAt(LuPixbuf *somSelf,  Environment *ev,
119                              LuPixbuf* p, long x, long y)
120{
121    LuPixbufData *somThis = LuPixbufGetData(somSelf);
122    int xlen = __min( somThis->width - x, p->getWidth( ev ) ) * somThis->bpp;
123    int ylen = __min( somThis->height - y, p->getHeight( ev ) );
124    int rowstribe = p->getRowSize( ev );
125    char *fromdt = (char *)p->getDataPtr( ev );
126    char *todt = (char *)somThis->data + ( somThis->rowsize * y );
127    for ( int i = 0; i < ylen; i++ )
128    {
129        char *from = fromdt + ( i * rowstribe );
130        char *to = todt + ( i * somThis->rowsize ) + ( x * somThis->bpp );
131        memcpy( to, from, xlen );
132    }
133}
134
135SOM_Scope void SOMLINK somDestruct(LuPixbuf *somSelf, octet doFree,
136                                   som3DestructCtrl* ctrl)
137{
138    LuPixbufData *somThis;
139    somDestructCtrl globalCtrl;
140    somBooleanVector myMask;
141    LuPixbuf_BeginDestructor;
142
143    // local LuPixbuf deinitialization code
144    SOMFree( somThis->data );
145    // local LuPixbuf deinitialization code end
146
147    LuPixbuf_EndDestructor;
148}
149
150
Note: See TracBrowser for help on using the repository browser.