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

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

subsequently load supported files in same directory, Next/Previous? menuitem (part of ticket #66)

File size: 5.1 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#define INCL_DOS
55#include <os2.h>
56#include <assert.h>
57
58#include "lupixbuf.xih"
59
60
61SOM_Scope void SOMLINK LuPixbufInit(LuPixbuf *somSelf,  Environment *ev,
62                                    somInitCtrl* ctrl, long w,
63                                    long h, short bpp)
64{
65    APIRET rc = 0;
66    LuPixbufData *somThis;
67    somInitCtrl globalCtrl;
68    somBooleanVector myMask;
69    LuPixbuf_BeginInitializer_LuPixbufInit;
70    LuPixbuf_Init_SOMObject_somDefaultInit(somSelf, ctrl);
71
72    // local LuPixbuf initialization code
73    somThis->width = w;
74    somThis->height = h;
75    somThis->bpp = bpp;
76    somThis->rowsize = ( somThis->width * somThis->bpp );
77    if ( bpp != 4 ) {
78        somThis->rowsize = (somThis->rowsize + 3) &~3;
79    }
80    somThis->dlen = somThis->rowsize * somThis->height;
81
82    //somPrintf( "LuPixbufInit: allocating %d bytes\n", somThis->dlen );
83
84    // To support HUGE pixbufs we need HMA
85    // (Is OBJ_ANY compatible with old (9.0xx) kernels?)
86    rc = DosAllocMem( &(somThis->data), somThis->dlen, PAG_COMMIT | fPERM | OBJ_ANY );
87    assert( rc == 0 );
88
89    memset( somThis->data, 0xff, somThis->dlen );
90}
91
92
93SOM_Scope long  SOMLINK getWidth(LuPixbuf *somSelf,  Environment *ev)
94{
95    LuPixbufData *somThis = LuPixbufGetData(somSelf);
96    return somThis->width;
97}
98
99SOM_Scope long  SOMLINK getHeight(LuPixbuf *somSelf,  Environment *ev)
100{
101    LuPixbufData *somThis = LuPixbufGetData(somSelf);
102    return somThis->height;
103}
104
105SOM_Scope short  SOMLINK getBpp(LuPixbuf *somSelf,  Environment *ev)
106{
107    LuPixbufData *somThis = LuPixbufGetData(somSelf);
108    return somThis->bpp;
109}
110
111SOM_Scope long  SOMLINK getRowSize(LuPixbuf *somSelf,  Environment *ev)
112{
113    LuPixbufData *somThis = LuPixbufGetData(somSelf);
114    return somThis->rowsize;
115}
116
117SOM_Scope long  SOMLINK getDataLen(LuPixbuf *somSelf,  Environment *ev)
118{
119    LuPixbufData *somThis = LuPixbufGetData(somSelf);
120    return somThis->dlen;
121}
122
123SOM_Scope void*  SOMLINK getDataPtr(LuPixbuf *somSelf,  Environment *ev)
124{
125    LuPixbufData *somThis = LuPixbufGetData(somSelf);
126    return somThis->data;
127}
128
129SOM_Scope void  SOMLINK putAt(LuPixbuf *somSelf,  Environment *ev,
130                              LuPixbuf* p, long x, long y)
131{
132    LuPixbufData *somThis = LuPixbufGetData(somSelf);
133    int xlen = __min( somThis->width - x, p->getWidth( ev ) ) * somThis->bpp;
134    int ylen = __min( somThis->height - y, p->getHeight( ev ) );
135    int rowstribe = p->getRowSize( ev );
136    char *fromdt = (char *)p->getDataPtr( ev );
137    char *todt = (char *)somThis->data + ( somThis->rowsize * y );
138    for ( int i = 0; i < ylen; i++ )
139    {
140        char *from = fromdt + ( i * rowstribe );
141        char *to = todt + ( i * somThis->rowsize ) + ( x * somThis->bpp );
142        memcpy( to, from, xlen );
143    }
144}
145
146SOM_Scope void SOMLINK somDestruct(LuPixbuf *somSelf, octet doFree,
147                                   som3DestructCtrl* ctrl)
148{
149    LuPixbufData *somThis;
150    somDestructCtrl globalCtrl;
151    somBooleanVector myMask;
152    LuPixbuf_BeginDestructor;
153
154    // local LuPixbuf deinitialization code
155    DosFreeMem( somThis->data );
156    // local LuPixbuf deinitialization code end
157
158    LuPixbuf_EndDestructor;
159}
160
161
Note: See TracBrowser for help on using the repository browser.