1 /*
2 * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * This file contains the skeleton code for generating functions to
28 * convert image data for the Java AWT. Nearly everything below is
29 * a call to a macro that is defined in one of the header files
30 * included in this directory. A description of the various macro
31 * packages available for customizing this skeleton and how to use
32 * this file to construct specific conversion functions is available
33 * in the README file that should also be included in this directory.
34 */
35
36 ImgConvertFcn NAME;
37
NAME(struct Hjava_awt_image_ColorModel * colormodel,int srcOX,int srcOY,int srcW,int srcH,void * srcpix,int srcOff,int srcBPP,int srcScan,int srcTotalWidth,int srcTotalHeight,int dstTotalWidth,int dstTotalHeight,ImgConvertData * cvdata,ImgColorData * clrdata)38 int NAME(struct Hjava_awt_image_ColorModel *colormodel,
39 int srcOX, int srcOY, int srcW, int srcH,
40 void *srcpix, int srcOff, int srcBPP, int srcScan,
41 int srcTotalWidth, int srcTotalHeight,
42 int dstTotalWidth, int dstTotalHeight,
43 ImgConvertData *cvdata, ImgColorData *clrdata)
44 {
45 DeclareScaleVars
46 DeclareInputVars
47 DeclareDecodeVars
48 DeclareAlphaVars
49 DeclareDitherVars
50 DeclareOutputVars
51 unsigned int pixel;
52 int red, green, blue;
53 IfAlpha(int alpha;)
54
55 InitInput(srcBPP);
56 InitScale(srcpix, srcOff, srcScan,
57 srcOX, srcOY, srcW, srcH,
58 srcTotalWidth, srcTotalHeight,
59 dstTotalWidth, dstTotalHeight);
60 InitOutput(cvdata, clrdata, DSTX1, DSTY1);
61 InitAlpha(cvdata, DSTY1, DSTX1, DSTX2);
62
63 InitPixelDecode(colormodel);
64 InitDither(cvdata, clrdata, dstTotalWidth);
65
66 RowLoop(srcOY) {
67 RowSetup(srcTotalHeight, dstTotalHeight,
68 srcTotalWidth, dstTotalWidth,
69 srcOY, srcpix, srcOff, srcScan);
70 StartDitherLine(cvdata, DSTX1, DSTY);
71 StartAlphaRow(cvdata, DSTX1, DSTY);
72 ColLoop(srcOX) {
73 ColSetup(srcTotalWidth, dstTotalWidth, pixel);
74 PixelDecode(colormodel, pixel, red, green, blue, alpha);
75 ApplyAlpha(cvdata, DSTX, DSTY, alpha);
76 DitherPixel(DSTX, DSTY, pixel, red, green, blue);
77 PutPixelInc(pixel, red, green, blue);
78 }
79 EndMaskLine();
80 EndOutputRow(cvdata, DSTY, DSTX1, DSTX2);
81 RowEnd(srcTotalHeight, dstTotalHeight, srcW, srcScan);
82 }
83 DitherBufComplete(cvdata, DSTX1);
84 BufComplete(cvdata, DSTX1, DSTY1, DSTX2, DSTY2);
85 return SCALESUCCESS;
86 }
87