0N/A/*
2362N/A * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#include "jni.h"
0N/A#include "awt_Mlib.h"
0N/A#include "java_awt_image_BufferedImage.h"
0N/A
0N/A#include <windows.h>
0N/A#include "alloc.h"
0N/A
0N/Aextern "C"
0N/A{
0N/A /*
0N/A * This is called by awt_ImagingLib.initLib() to figure out if there
0N/A * is a native imaging lib tied to the ImagingLib.java (other than
0N/A * the shared medialib).
0N/A */
0N/A mlib_status awt_getImagingLib(JNIEnv *env, mlibFnS_t *sMlibFns,
0N/A mlibSysFnS_t *sMlibSysFns) {
0N/A static HINSTANCE hDLL = NULL;
0N/A mlibSysFnS_t tempSysFns;
0N/A mlib_status ret = MLIB_SUCCESS;
0N/A
4305N/A /* Try to receive handle for the library. Routine should find
4305N/A * the library successfully because this library is already
4305N/A * loaded to the process space by the System.loadLibrary() call.
4305N/A * Here we just need to get handle to initialize the pointers to
4305N/A * required mlib routines.
0N/A */
4305N/A hDLL = ::GetModuleHandle(TEXT("mlib_image.dll"));
0N/A
0N/A if (hDLL == NULL) {
0N/A return MLIB_FAILURE;
0N/A }
0N/A
0N/A /* Initialize pointers to medilib routines... */
0N/A tempSysFns.createFP = (MlibCreateFP_t)
0N/A ::GetProcAddress(hDLL, "j2d_mlib_ImageCreate");
0N/A if (tempSysFns.createFP == NULL) {
0N/A ret = MLIB_FAILURE;
0N/A }
0N/A
0N/A if (ret == MLIB_SUCCESS) {
0N/A tempSysFns.createStructFP = (MlibCreateStructFP_t)
0N/A ::GetProcAddress(hDLL, "j2d_mlib_ImageCreateStruct");
0N/A if (tempSysFns.createStructFP == NULL) {
0N/A ret = MLIB_FAILURE;
0N/A }
0N/A }
0N/A
0N/A if (ret == MLIB_SUCCESS) {
0N/A tempSysFns.deleteImageFP = (MlibDeleteFP_t)
0N/A ::GetProcAddress(hDLL, "j2d_mlib_ImageDelete");
0N/A if (tempSysFns.deleteImageFP == NULL) {
0N/A ret = MLIB_FAILURE;
0N/A }
0N/A }
0N/A if (ret == MLIB_SUCCESS) {
0N/A *sMlibSysFns = tempSysFns;
0N/A }
0N/A
0N/A mlib_status (*fPtr)();
0N/A mlibFnS_t* pMlibFns = sMlibFns;
0N/A int i = 0;
0N/A while ((ret == MLIB_SUCCESS) && (pMlibFns[i].fname != NULL)) {
0N/A fPtr = (mlib_status (*)())
0N/A ::GetProcAddress(hDLL, pMlibFns[i].fname);
0N/A if (fPtr != NULL) {
0N/A pMlibFns[i].fptr = fPtr;
0N/A } else {
0N/A ret = MLIB_FAILURE;
0N/A }
0N/A i++;
0N/A }
0N/A
0N/A return ret;
0N/A }
0N/A
0N/A mlib_start_timer awt_setMlibStartTimer() {
0N/A return NULL;
0N/A }
0N/A
0N/A mlib_stop_timer awt_setMlibStopTimer() {
0N/A return NULL;
0N/A }
0N/A
0N/A void awt_getBIColorOrder(int type, int *colorOrder) {
0N/A switch(type) {
0N/A case java_awt_image_BufferedImage_TYPE_INT_ARGB:
0N/A case java_awt_image_BufferedImage_TYPE_INT_ARGB_PRE:
0N/A colorOrder[0] = 2;
0N/A colorOrder[1] = 1;
0N/A colorOrder[2] = 0;
0N/A colorOrder[3] = 3;
0N/A break;
0N/A case java_awt_image_BufferedImage_TYPE_INT_BGR:
0N/A colorOrder[0] = 0;
0N/A colorOrder[1] = 1;
0N/A colorOrder[2] = 2;
0N/A break;
0N/A case java_awt_image_BufferedImage_TYPE_INT_RGB:
0N/A colorOrder[0] = 2;
0N/A colorOrder[1] = 1;
0N/A colorOrder[2] = 0;
0N/A break;
0N/A case java_awt_image_BufferedImage_TYPE_4BYTE_ABGR:
0N/A case java_awt_image_BufferedImage_TYPE_4BYTE_ABGR_PRE:
0N/A colorOrder[0] = 3;
0N/A colorOrder[1] = 2;
0N/A colorOrder[2] = 1;
0N/A colorOrder[3] = 0;
0N/A break;
0N/A case java_awt_image_BufferedImage_TYPE_3BYTE_BGR:
0N/A colorOrder[0] = 2;
0N/A colorOrder[1] = 1;
0N/A colorOrder[2] = 0;
0N/A break;
0N/A case java_awt_image_BufferedImage_TYPE_USHORT_565_RGB:
0N/A case java_awt_image_BufferedImage_TYPE_USHORT_555_RGB:
0N/A colorOrder[0] = 0;
0N/A colorOrder[1] = 1;
0N/A colorOrder[2] = 2;
0N/A break;
0N/A case java_awt_image_BufferedImage_TYPE_BYTE_GRAY:
0N/A case java_awt_image_BufferedImage_TYPE_USHORT_GRAY:
0N/A case java_awt_image_BufferedImage_TYPE_BYTE_BINARY:
0N/A case java_awt_image_BufferedImage_TYPE_BYTE_INDEXED:
0N/A colorOrder[0] = 0;
0N/A break;
0N/A }
0N/A }
0N/A}