/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 in the LICENSE file that
* accompanied this code).
*
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* FUNCTION
* mlib_ImageCreateStruct - create image data structure
* mlib_ImageCreate - create image data structure and allocate
* memory for image data
* mlib_ImageDelete - delete image
* mlib_ImageCreateSubimage - create sub-image
*
* mlib_ImageCreateRowTable - create row starts pointer table
* mlib_ImageDeleteRowTable - delete row starts pointer table
*
* mlib_ImageSetPaddings - set paddings for clipping box borders
*
* mlib_ImageSetFormat - set image format
*
* SYNOPSIS
* mlib_image *mlib_ImageCreateStruct(mlib_type type,
* mlib_s32 channels,
* mlib_s32 width,
* mlib_s32 height,
* mlib_s32 stride,
* const void *data)
*
* mlib_image *mlib_ImageCreate(mlib_type type,
* mlib_s32 channels,
* mlib_s32 width,
* mlib_s32 height)
*
* void mlib_ImageDelete(mlib_image *img)
*
* mlib_image *mlib_ImageCreateSubimage(mlib_image *img,
* mlib_s32 x,
* mlib_s32 y,
* mlib_s32 w,
* mlib_s32 h)
*
* void *mlib_ImageCreateRowTable(mlib_image *img)
*
* void mlib_ImageDeleteRowTable(mlib_image *img)
*
* mlib_status mlib_ImageSetPaddings(mlib_image *img,
* mlib_u8 left,
* mlib_u8 top,
* mlib_u8 right,
* mlib_u8 bottom)
*
* mlib_status mlib_ImageSetFormat(mlib_image *img,
* mlib_format format)
* ARGUMENTS
* img pointer to image data structure
* type image data type, one of MLIB_BIT, MLIB_BYTE, MLIB_SHORT,
* MLIB_USHORT, MLIB_INT, MLIB_FLOAT or MLIB_DOUBLE
* channels number of image channels
* width image width in pixels
* height image height in pixels
* stride linebytes( bytes to next row) of the image
* data pointer to image data allocated by user
* x x coordinate of the left border in the source image
* y y coordinate of the top border in the source image
* w width of the sub-image
* h height of the sub-image
* left clipping box left padding
* top clipping box top padding
* right clipping box right padding
* bottom clipping box bottom padding
* format image format
*
* DESCRIPTION
* mlib_ImageCreateStruct() creates a mediaLib image data structure
* using parameter supplied by user.
*
* mlib_ImageCreate() creates a mediaLib image data structure and
* allocates memory space for image data.
*
* mlib_ImageDelete() deletes the mediaLib image data structure
* and frees the memory space of the image data if it is allocated
* through mlib_ImageCreate().
*
* mlib_ImageCreateSubimage() creates a mediaLib image structure
* for a sub-image based on a source image.
*
* mlib_ImageCreateRowTable() creates row starts pointer table and
* puts it into mlib_image->state field.
*
* mlib_ImageDeleteRowTable() deletes row starts pointer table from
* image and puts NULL into mlib_image->state field.
*
* mlib_ImageSetPaddings() sets new values for the clipping box paddings
*
* mlib_ImageSetFormat() sets new value for the image format
*/
#include <stdlib.h>
#include "mlib_image.h"
#include "mlib_ImageRowTable.h"
#include "mlib_ImageCreate.h"
#include "safe_math.h"
/***************************************************************/
const void *data)
{
/* for some ugly functions calling with incorrect parameters */
return NULL;
}
/* Check if stride == width
* If it is then image can be treated as a 1-D vector
*/
return NULL;
}
switch (type) {
case MLIB_DOUBLE:
return NULL;
}
wb *= 8;
mask = 7;
break;
case MLIB_FLOAT:
case MLIB_INT:
return NULL;
}
wb *= 4;
mask = 3;
break;
case MLIB_USHORT:
case MLIB_SHORT:
return NULL;
}
wb *= 2;
mask = 1;
break;
case MLIB_BYTE:
// wb is ready
mask = 0;
break;
case MLIB_BIT:
return NULL;
}
mask = 0;
break;
default:
return NULL;
}
return NULL;
}
}
return image;
}
/***************************************************************/
const void *data)
{
if (stride <= 0) {
return NULL;
}
return NULL;
}
}
return image;
}
/***************************************************************/
{
void *data;
/* sanity check */
return NULL;
};
return NULL;
}
switch (type) {
case MLIB_DOUBLE:
return NULL;
}
wb *= 8;
break;
case MLIB_FLOAT:
case MLIB_INT:
return NULL;
}
wb *= 4;
break;
case MLIB_USHORT:
case MLIB_SHORT:
return NULL;
}
wb *= 2;
break;
case MLIB_BYTE:
// wb is ready
break;
case MLIB_BIT:
return NULL;
}
break;
default:
return NULL;
}
return NULL;
}
return NULL;
}
return NULL;
};
}
return image;
}
/***************************************************************/
{
}
}
/***************************************************************/
mlib_s32 x,
mlib_s32 y,
mlib_s32 w,
mlib_s32 h)
{
void *data;
/* sanity check */
/* clip the sub-image with respect to the parent image */
if (((x + w) <= 0) || ((y + h) <= 0) ||
return NULL;
}
else {
if (x < 0) {
w += x; /* x is negative */
x = 0;
}
if (y < 0) {
h += y; /* y is negative */
y = 0;
}
if ((x + w) > width) {
w = width - x;
}
if ((y + h) > height) {
h = height - y;
}
}
/* compute sub-image origin */
switch (type) {
case MLIB_DOUBLE:
break;
case MLIB_FLOAT:
case MLIB_INT:
break;
case MLIB_USHORT:
case MLIB_SHORT:
break;
case MLIB_BYTE:
break;
case MLIB_BIT:
break;
default:
return NULL;
}
w,
h,
data);
return subimage;
}
/***************************************************************/
const mlib_image *src,
mlib_s32 x,
mlib_s32 y,
mlib_s32 w,
mlib_s32 h)
{
switch (type) {
case MLIB_DOUBLE:
break;
case MLIB_FLOAT:
case MLIB_INT:
break;
case MLIB_USHORT:
case MLIB_SHORT:
break;
case MLIB_BYTE:
break;
case MLIB_BIT:
bitoffset &= 7;
break;
default:
return NULL;
}
if (h > 0) {
} else {
h = - h;
}
}
return dst;
}
/***************************************************************/
{
rtable[0] = 0;
for (i = 0; i < im_height; i++) {
}
}
/***************************************************************/
{
void **state;
if (!state) return;
}
/***************************************************************/
{
return MLIB_SUCCESS;
}
/***************************************************************/
{
return MLIB_SUCCESS;
}
/***************************************************************/