javauis/m3g_akn/src/m3g_jsr184.inl
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /*!
       
    20  * \file \brief Global methods for JSR-184
       
    21  *
       
    22  * This file is <em>included</em>, not linked, by specific VM bindings.
       
    23  *
       
    24  */
       
    25 
       
    26 #ifndef M3G_JAVA_INCLUDE
       
    27 #   error included by m3g_<platform>_java_api.c; do not compile separately.
       
    28 #endif
       
    29 
       
    30 #include <M3G/m3g_core.h>
       
    31 #include "m3g_jsr184.h"
       
    32 
       
    33 /*----------------------------------------------------------------------
       
    34  * Internal functions
       
    35  *--------------------------------------------------------------------*/
       
    36 
       
    37 /*!
       
    38  * \brief Returns the number of bytes per pixel for a JSR-184 pixel
       
    39  * format
       
    40  *
       
    41  * \note Dependent on constants in Image2D.java
       
    42  */
       
    43 static M3Guint jsr184BytesPerPixel(int jsrFormat)
       
    44 {
       
    45     switch (jsrFormat)
       
    46     {
       
    47     case M3G_ALPHA:
       
    48         return 1;
       
    49     case M3G_LUMINANCE:
       
    50         return 1;
       
    51     case M3G_LUMINANCE_ALPHA:
       
    52         return 2;
       
    53     case M3G_RGB:
       
    54         return 3;
       
    55     case M3G_RGBA:
       
    56         return 4;
       
    57     default:
       
    58         return 0;
       
    59     }
       
    60 }
       
    61 
       
    62 /*!
       
    63  * \brief Return a MIDP exception string corresponding to an M3G error
       
    64  */
       
    65 static const char *jsr184Exception(M3Genum errorCode)
       
    66 {
       
    67     switch (errorCode)
       
    68     {
       
    69     case M3G_NO_ERROR:
       
    70         return NULL;
       
    71     case M3G_OUT_OF_MEMORY:
       
    72         return "java/lang/OutOfMemoryError";
       
    73     case M3G_INVALID_OPERATION:
       
    74         return "java/lang/IllegalStateException";
       
    75     case M3G_INVALID_INDEX:
       
    76         return "java/lang/IndexOutOfBoundsException";
       
    77     case M3G_NULL_POINTER:
       
    78         return "java/lang/NullPointerException";
       
    79     case M3G_ARITHMETIC_ERROR:
       
    80         return "java/lang/ArithmeticException";
       
    81     case M3G_IO_ERROR:
       
    82         return "java/io/IOException";
       
    83     default:
       
    84         return "java/lang/IllegalArgumentException";
       
    85     }
       
    86 }