source: trunk/Lucide/plugins/ludoc/lupixbuf.cpp

Last change on this file was 647, checked in by Gregg Young, 3 years ago

Fix problems identified by CPPCheck

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