⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gxj_image.c

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *    * * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). *  * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA *  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. *//** * \file * Immutable image functions that needed to be implemented for each port. */#include <kni.h>#include <string.h>#include <midpMalloc.h>#include <midp_logging.h>#include <gxapi_constants.h>#include "gxj_intern_graphics.h"#include "gxj_intern_image.h"#include "gxj_intern_putpixel.h"static void clipped_blit(gxj_screen_buffer* dst, int dstX, int dstY,			 gxj_screen_buffer* src, const jshort *clip);extern void unclipped_blit(unsigned short *dstRaster, int dstSpan,			   unsigned short *srcRaster, int srcSpan,			   int height, int width, gxj_screen_buffer * dst);/** * Renders the contents of the specified mutable image * onto the destination specified. * * @param srcImagePtr         pointer to source image * @param graphicsDestination pointer to destination graphics object * @param clip                pointer to the clip * @param x_dest              x-coordinate in the destination * @param y_dest              y-coordinate in the destination */voiddraw_image(gxj_screen_buffer *imageSBuf,	     gxj_screen_buffer *gSBuf,	     const jshort *clip,	     jint x_dest, jint y_dest) {  gxj_screen_buffer *destSBuf = getScreenBuffer(gSBuf);  const jshort clipX1 = clip[0];  const jshort clipY1 = clip[1];  const jshort clipX2 = clip[2];  const jshort clipY2 = clip[3];  REPORT_CALL_TRACE(LC_LOWUI, "LF:STUB:MutableImage_render_Image()\n");  CHECK_SBUF_CLIP_BOUNDS(destSBuf, clip);  if (imageSBuf->alphaData == NULL) {    if (x_dest >= clipX1 && y_dest >= clipY1 &&       (x_dest + imageSBuf->width) <= clipX2 &&       (y_dest + imageSBuf->height) <= clipY2) {      unclipped_blit(&destSBuf->pixelData[y_dest*destSBuf->width+x_dest],		    destSBuf->width<<1,		    &imageSBuf->pixelData[0], imageSBuf->width<<1,		    imageSBuf->height, imageSBuf->width<<1,destSBuf);    } else {      clipped_blit(destSBuf, x_dest, y_dest, imageSBuf, clip);    }  } else {    copy_imageregion(imageSBuf, destSBuf,		     clip, x_dest, y_dest,		     imageSBuf->width, imageSBuf->height,		     0, 0, 0);  }}/** * Renders the contents of the specified region of this * mutable image onto the destination specified. * * @param srcImagePtr         pointer to source image * @param graphicsDestination pointer to destination graphics object * @param clip                pointer to the clip * @param x_dest              x-coordinate in the destination * @param y_dest              y-coordinate in the destination * @param width               width of the region * @param height              height of the region * @param x_src               x-coord of the region * @param y_src               y-coord of the region * @param transform           transform to be applied to the region */voiddraw_imageregion(gxj_screen_buffer *imageSBuf,		 gxj_screen_buffer *gSBuf,		 const jshort *clip,		 jint x_dest, jint y_dest,		 jint width, jint height,		 jint x_src, jint y_src,		 jint transform) {  gxj_screen_buffer *dstSBuf = getScreenBuffer(gSBuf);  REPORT_CALL_TRACE(LC_LOWUI, "LF:STUB:MutableImage_render_imageRegion()\n");  CHECK_SBUF_CLIP_BOUNDS(dstSBuf, clip);  copy_imageregion(imageSBuf, dstSBuf,                  clip, x_dest, y_dest, width, height, x_src, y_src, transform);}static voidclipped_blit(gxj_screen_buffer* dst, int dstX, int dstY, gxj_screen_buffer* src, const jshort *clip) {  int width, height;        /* computed width and height */  int startX; int startY;   /* x,y into the dstRaster */  int negY, negX;           /* x,y into the srcRaster */  int diff;  unsigned short* srcRaster;  unsigned short* dstRaster;  const jshort clipX1 = clip[0];  const jshort clipY1 = clip[1];  const jshort clipX2 = clip[2];  const jshort clipY2 = clip[3];  if ((dstX >= clipX2) || (dstY >= clipY2))      return;  if (dstX < 0) {    startX = 0;    negX   = -dstX;  } else {    startX = dstX;    negX   = 0;  }  if (dstY < 0) {    startY = 0;    negY   = -dstY;  } else {    startY = dstY;    negY   = 0;  }  width = src->width - negX;  /* clip left edge */  if ((diff=clipX1-startX) > 0) {    negX   += diff;    width  -= diff;    startX  = clipX1;  }  /* clip right edge */  if ((diff=clipX2-startX) < width) {    width = diff;  }  if (width <= 0)    return;  height = src->height - negY;  /* clip top edge */  if ((diff=clipY1-startY) > 0) {    negY   += diff;    height -= diff;    startY  = clipY1;   }  /* clip bottom edge */  if ((diff=clipY2-startY) < height) {    height = diff;  }  if (height <= 0)    return;  srcRaster = src->pixelData + (negY ? (negY   * src->width) : 0) + negX;  dstRaster = dst->pixelData +         (startY * dst->width)      + startX;  unclipped_blit(dstRaster, dst->width<<1,		 srcRaster, src->width<<1, height, width<<1,dst);}/** * Renders the contents of the specified region of this * mutable image onto the destination specified. * * @param src                 pointer to source screen buffer * @param dest                pointer to destination screen buffer * @param x_dest              x-coordinate in the destination * @param y_dest              y-coordinate in the destination * @param width               width of the region * @param height              height of the region * @param transform           transform to be applied to the region */voidcreate_transformed_imageregion(gxj_screen_buffer* src, gxj_screen_buffer* dest, jint src_x, jint src_y,                             jint width, jint height, jint transform) {  int srcX;  int srcY;  int xStart;  int yStart;  int xIncr;  int yIncr;  int destX;  int destY;  int yCounter;  int xCounter;  /* set dimensions of image being created,     depending on transform */  if (transform & TRANSFORM_INVERTED_AXES) {    dest->width  = height;    dest->height = width;  } else {    dest->width  = width;    dest->height = height;  }  if (transform & TRANSFORM_Y_FLIP) {    yStart = height-1;    yIncr = -1;  } else {    yStart = 0;    yIncr = +1;  }  if (transform & TRANSFORM_X_FLIP) {    xStart = width-1;    xIncr = -1;  } else {    xStart = 0;    xIncr = +1;  }  for (srcY = src_y, destY = yStart, yCounter = 0;       yCounter < height;       srcY++, destY+=yIncr, yCounter++) {    int srcYwidth = srcY * src->width;    int destYwidth = destY * dest->width;    for (srcX = src_x, destX = xStart, xCounter = 0;         xCounter < width;         srcX++, destX+=xIncr, xCounter++) {      if ( transform & TRANSFORM_INVERTED_AXES ) {          dest->pixelData[destX * dest->width + destY] =            src->pixelData[srcYwidth /*srcY*src->width*/ + srcX];        if (src->alphaData != NULL) {            dest->alphaData[destX * dest->width + destY] =                src->alphaData[srcYwidth /*srcY*src->width*/ + srcX];        }      } else {        dest->pixelData[destYwidth /*destY * dest->width*/ + destX] =                   src->pixelData[srcYwidth /*srcY*src->width*/ + srcX];        if (src->alphaData != NULL) {            dest->alphaData[destYwidth /*destY * dest->width*/ + destX] =                src->alphaData[srcYwidth /*srcY*src->width*/ + srcX];        }      }    } /*for x*/  } /* for y */}/** * Renders the contents of the specified region of this * mutable image onto the destination specified. * * @param src                 pointer to source screen buffer * @param dest                pointer to destination screen buffer

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -