-/* $Id: texutil.c,v 1.7 2000/09/13 22:07:20 brianp Exp $ */
+/* $Id: texutil.c,v 1.11 2000/12/26 05:09:29 keithw Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.4
- *
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#include "image.h"
#include "mem.h"
#include "texutil.h"
-#include "types.h"
+#include "mtypes.h"
#endif
/* store as 8-bit texels */
if (wScale == 1 && hScale == 1) {
/* no scaling needed - fast case */
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
GLubyte *dst = (GLubyte *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
+ GLuint i;
+ for (i = 0 ; i < dstWidth ; i++)
+ fprintf(stderr, "%02x ", src[i]);
+ fprintf(stderr, "\n");
MEMCPY(dst, src, dstWidth * sizeof(GLubyte));
dst += dstRowStride;
src += srcStride;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
dst[col] = src[col / wScale];
else {
/* store as 16-bit texels */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
GLushort *dst = (GLushort *) dstImage;
GLint row, col;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
for (col = 0; col < dstWidth; col++) {
if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5) {
/* special, optimized case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
GLushort *dst = (GLushort *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLushort *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLushort *src = (const GLushort *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
dst[col] = src[col / wScale];
else if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE) {
/* general case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
#ifdef DO_32BIT_STORES
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
GLint col3 = (col / wScale) * 3;
else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
/* general case (used by Quake3) */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
#ifdef DO_32BIT_STORES
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
GLint col4 = (col / wScale) * 4;
if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV){
/* special, optimized case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
GLushort *dst = (GLushort *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLushort *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLushort *src = (const GLushort *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
dst[col] = src[col / wScale];
else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
/* general case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
#ifdef DO_32BIT_STORES
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
GLint col4 = (col / wScale) * 4;
if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV){
/* special, optimized case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
GLushort *dst = (GLushort *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLushort *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLushort *src = (const GLushort *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
dst[col] = src[col / wScale];
else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
/* general case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
GLushort *dst = (GLushort *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
GLint col4 = (col / wScale) * 4;
if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV){
/* special, optimized case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
- GLuint *dst = dstImage;
+ GLuint *dst = (GLuint *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
MEMCPY(dst, src, dstWidth * sizeof(GLuint));
}
else {
/* must rescale image */
- GLuint *dst = dstImage;
+ GLuint *dst = (GLuint *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLuint *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLuint *src = (const GLuint *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
dst[col] = src[col / wScale];
else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
/* general case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
- GLuint *dst = dstImage;
+ GLuint *dst = (GLuint *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint col, col4;
}
else {
/* must rescale image */
- GLuint *dst = dstImage;
+ GLuint *dst = (GLuint *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
GLint col4 = (col / wScale) * 4;
else if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE) {
/* general case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
srcWidth, srcFormat, srcType);
- GLuint *dst = dstImage;
+ GLuint *dst = (GLuint *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint col, col3;
}
else {
/* must rescale image */
- GLuint *dst = dstImage;
+ GLuint *dst = (GLuint *) dstImage;
GLint row;
for (row = 0; row < dstHeight; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < dstWidth; col++) {
GLint col3 = (col / wScale) * 3;
}
if (dstFormat == MESA_FF_R8_G8_B8) {
/* set alpha bytes to 0xff */
- GLuint i;
+ GLint i;
GLubyte *dst = (GLubyte *) dstImage;
for (i = 0; i < dstWidth * dstHeight; i++) {
dst[i * 4 + 3] = 0xff;
* Replace a subregion of a texture image with new data.
* Input:
* dstFormat - destination image format
- * dstXoffset, dstYoffset - destination for new subregion
- * dstWidth, dstHeight - total size of dest image
+ * dstXoffset, dstYoffset - destination for new subregion (in texels)
+ * dstWidth, dstHeight - total size of dest image (in texels)
* dstImage - pointer to dest image
- * dstRowStride - bytes to jump between image rows
- * width, height - size of region to copy/replace
+ * dstRowStride - bytes to jump between image rows (in bytes)
+ * width, height - size of region to copy/replace (in texels)
* srcWidth, srcHeight - size of the corresponding gl_texture_image
* srcFormat, srcType - source image format and datatype
* srcImage - source image
dstYoffset *= hScale;
/* XXX hscale != 1 and wscale != 1 not tested!!!! */
-
+
switch (dstFormat) {
case MESA_I8:
case MESA_L8:
/* store as 8-bit texels */
if (wScale == 1 && hScale == 1) {
/* no scaling needed - fast case */
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLubyte *dst = (GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = src[col / wScale];
else {
/* store as 16-bit texels */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLushort *dst = (GLushort *) ((GLubyte *) dstImage
GLint row, col;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
for (col = 0; col < width; col++) {
if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5) {
/* special, optimized case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLushort *dst = (GLushort *) ((GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLushort *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLushort *src = (const GLushort *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = src[col / wScale];
else if (srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE) {
/* general case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLushort *dst = (GLushort *) ((GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
GLint col3 = (col / wScale) * 3;
else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
/* general case (used by Quake3) */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLushort *dst = (GLushort *) ((GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
GLint col4 = (col / wScale) * 4;
if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV){
/* special, optimized case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLushort *dst = (GLushort *) ((GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLushort *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLushort *src = (const GLushort *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = src[col / wScale];
else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
/* general case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLushort *dst = (GLushort *) ((GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
GLint col4 = (col / wScale) * 4;
if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV){
/* special, optimized case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLushort *dst = (GLushort *) ((GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLushort *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLushort *src = (const GLushort *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = src[col / wScale];
else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
/* general case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLushort *dst = (GLushort *) ((GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
GLint col4 = (col / wScale) * 4;
case MESA_A8_R8_G8_B8:
case MESA_FF_R8_G8_B8:
/* 32-bit texels */
- if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV){
+ if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) {
/* special, optimized case */
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLuint *dst = (GLuint *) ((GLubyte *) dstImage
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLuint *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLuint *src = (const GLuint *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
dst[col] = src[col / wScale];
dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
}
}
+ if (dstFormat == MESA_FF_R8_G8_B8) {
+ /* set alpha bytes to 0xff */
+ GLint row, col;
+ GLubyte *dst = (GLubyte *) dstImage
+ + dstYoffset * dstRowStride + dstXoffset * 4;
+ assert(wScale == 1 && hScale == 1); /* XXX not done */
+ for (row = 0; row < height; row++) {
+ for (col = 0; col < width; col++) {
+ dst[col * 4 + 3] = 0xff;
+ }
+ dst = dst + dstRowStride;
+ }
+ }
}
else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) {
/* general case */
+ const GLubyte aMask = (dstFormat==MESA_FF_R8_G8_B8) ? 0xff : 0x00;
if (wScale == 1 && hScale == 1) {
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
const GLint srcStride = _mesa_image_row_stride(packing,
width, srcFormat, srcType);
GLuint *dst = (GLuint *) ((GLubyte *) dstImage
GLubyte r = src[col4 + 0];
GLubyte g = src[col4 + 1];
GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
+ GLubyte a = src[col4 + 3] | aMask;
dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
}
src += srcStride;
GLint row;
for (row = 0; row < height; row++) {
GLint srcRow = row / hScale;
- const GLubyte *src = _mesa_image_address(packing, srcImage,
- srcWidth, srcHeight, srcFormat, srcType, 0, srcRow, 0);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(packing, srcImage, srcWidth,
+ srcHeight, srcFormat, srcType, 0, srcRow, 0);
GLint col;
for (col = 0; col < width; col++) {
GLint col4 = (col / wScale) * 4;
GLubyte r = src[col4 + 0];
GLubyte g = src[col4 + 1];
GLubyte b = src[col4 + 2];
- GLubyte a = src[col4 + 3];
+ GLubyte a = src[col4 + 3] | aMask;
dst[col] = (a << 24) | (r << 16) | (g << 8) | b;
}
dst = (GLuint *) ((GLubyte *) dst + dstRowStride);
/* can't handle this source format/type combination */
return GL_FALSE;
}
- if (dstFormat == MESA_FF_R8_G8_B8) {
- /* set alpha bytes to 0xff */
- GLint row, col;
- GLubyte *dst = (GLubyte *) dstImage
- + dstYoffset * dstRowStride + dstXoffset;
- for (row = 0; row < height; row++) {
- for (col = 0; col < width; col++) {
- dst[col * 4 + 3] = 0xff;
- }
- dst = dst + dstRowStride;
- }
- }
break;