< prev index next >

src/java.desktop/share/native/common/awt/medialib/mlib_ImageCreate.c

Print this page
rev 49551 : 8201226: missing JNIEXPORT / JNICALL at some places in function declarations/implementations


 210     return NULL;
 211   }
 212 
 213   image -> flags    = ((width & 0xf) << 8);          /* set width field */
 214   image -> flags   |= ((stride & 0xf) << 16);        /* set stride field */
 215   image -> flags   |= ((height & 0xf) << 12);        /* set height field */
 216   image -> flags   |= (mlib_addr)data & 0xff;
 217   image -> flags   |= MLIB_IMAGE_USERALLOCATED;      /* user allocated data */
 218 
 219   if ((stride != wb) ||
 220       ((type == MLIB_BIT) && (stride * 8 != width * channels))) {
 221     image -> flags |= MLIB_IMAGE_ONEDVECTOR;
 222   }
 223 
 224   image -> flags &= MLIB_IMAGE_ATTRIBUTESET;
 225 
 226   return image;
 227 }
 228 
 229 /***************************************************************/
 230 mlib_image *mlib_ImageCreateStruct(mlib_type  type,
 231                                    mlib_s32   channels,
 232                                    mlib_s32   width,
 233                                    mlib_s32   height,
 234                                    mlib_s32   stride,
 235                                    const void *data)
 236 {
 237   mlib_image *image;
 238   if (stride <= 0) {
 239     return NULL;
 240   }
 241 
 242   image = (mlib_image *)mlib_malloc(sizeof(mlib_image));
 243   if (image == NULL) {
 244     return NULL;
 245   }
 246 
 247   if (mlib_ImageSet(image, type, channels, width, height, stride, data) == NULL) {
 248     mlib_free(image);
 249     image = NULL;
 250   }
 251 
 252   return image;
 253 }
 254 
 255 /***************************************************************/
 256 mlib_image *mlib_ImageCreate(mlib_type type,
 257                              mlib_s32  channels,
 258                              mlib_s32  width,
 259                              mlib_s32  height)
 260 {
 261   mlib_image *image;
 262   mlib_s32        wb;                /* width in bytes */
 263   void       *data;
 264 
 265 /* sanity check */
 266   if (width <= 0 || height <= 0 || channels < 1 || channels > 4) {
 267     return NULL;
 268   };
 269 
 270   if (!SAFE_TO_MULT(width, channels)) {
 271     return NULL;
 272   }
 273 
 274   wb = width * channels;
 275 
 276   switch (type) {


 335   image -> format   = MLIB_FORMAT_UNKNOWN;
 336 
 337   image -> paddings[0] = 0;
 338   image -> paddings[1] = 0;
 339   image -> paddings[2] = 0;
 340   image -> paddings[3] = 0;
 341 
 342   image -> bitoffset = 0;
 343 
 344   if ((type == MLIB_BIT) && (wb * 8 != width * channels)) {
 345     image -> flags |= MLIB_IMAGE_ONEDVECTOR;       /* not 1-d vector */
 346   }
 347 
 348   image -> flags &= MLIB_IMAGE_ATTRIBUTESET;
 349   image -> state  = NULL;
 350 
 351   return image;
 352 }
 353 
 354 /***************************************************************/
 355 void mlib_ImageDelete(mlib_image *img)
 356 {
 357   if (img == NULL) return;
 358   if ((img -> flags & MLIB_IMAGE_USERALLOCATED) == 0) {
 359     mlib_free(img -> data);
 360   }
 361 
 362   mlib_ImageDeleteRowTable(img);
 363   mlib_free(img);
 364 }
 365 
 366 /***************************************************************/
 367 mlib_image *mlib_ImageCreateSubimage(mlib_image *img,
 368                                      mlib_s32   x,
 369                                      mlib_s32   y,
 370                                      mlib_s32   w,
 371                                      mlib_s32   h)
 372 {
 373   mlib_image     *subimage;
 374   mlib_type      type;
 375   mlib_s32       channels;




 210     return NULL;
 211   }
 212 
 213   image -> flags    = ((width & 0xf) << 8);          /* set width field */
 214   image -> flags   |= ((stride & 0xf) << 16);        /* set stride field */
 215   image -> flags   |= ((height & 0xf) << 12);        /* set height field */
 216   image -> flags   |= (mlib_addr)data & 0xff;
 217   image -> flags   |= MLIB_IMAGE_USERALLOCATED;      /* user allocated data */
 218 
 219   if ((stride != wb) ||
 220       ((type == MLIB_BIT) && (stride * 8 != width * channels))) {
 221     image -> flags |= MLIB_IMAGE_ONEDVECTOR;
 222   }
 223 
 224   image -> flags &= MLIB_IMAGE_ATTRIBUTESET;
 225 
 226   return image;
 227 }
 228 
 229 /***************************************************************/
 230 JNIEXPORT mlib_image* JNICALL mlib_ImageCreateStruct(mlib_type  type,
 231                                    mlib_s32   channels,
 232                                    mlib_s32   width,
 233                                    mlib_s32   height,
 234                                    mlib_s32   stride,
 235                                    const void *data)
 236 {
 237   mlib_image *image;
 238   if (stride <= 0) {
 239     return NULL;
 240   }
 241 
 242   image = (mlib_image *)mlib_malloc(sizeof(mlib_image));
 243   if (image == NULL) {
 244     return NULL;
 245   }
 246 
 247   if (mlib_ImageSet(image, type, channels, width, height, stride, data) == NULL) {
 248     mlib_free(image);
 249     image = NULL;
 250   }
 251 
 252   return image;
 253 }
 254 
 255 /***************************************************************/
 256 JNIEXPORT mlib_image* JNICALL mlib_ImageCreate(mlib_type type,
 257                              mlib_s32  channels,
 258                              mlib_s32  width,
 259                              mlib_s32  height)
 260 {
 261   mlib_image *image;
 262   mlib_s32        wb;                /* width in bytes */
 263   void       *data;
 264 
 265 /* sanity check */
 266   if (width <= 0 || height <= 0 || channels < 1 || channels > 4) {
 267     return NULL;
 268   };
 269 
 270   if (!SAFE_TO_MULT(width, channels)) {
 271     return NULL;
 272   }
 273 
 274   wb = width * channels;
 275 
 276   switch (type) {


 335   image -> format   = MLIB_FORMAT_UNKNOWN;
 336 
 337   image -> paddings[0] = 0;
 338   image -> paddings[1] = 0;
 339   image -> paddings[2] = 0;
 340   image -> paddings[3] = 0;
 341 
 342   image -> bitoffset = 0;
 343 
 344   if ((type == MLIB_BIT) && (wb * 8 != width * channels)) {
 345     image -> flags |= MLIB_IMAGE_ONEDVECTOR;       /* not 1-d vector */
 346   }
 347 
 348   image -> flags &= MLIB_IMAGE_ATTRIBUTESET;
 349   image -> state  = NULL;
 350 
 351   return image;
 352 }
 353 
 354 /***************************************************************/
 355 JNIEXPORT void JNICALL mlib_ImageDelete(mlib_image *img)
 356 {
 357   if (img == NULL) return;
 358   if ((img -> flags & MLIB_IMAGE_USERALLOCATED) == 0) {
 359     mlib_free(img -> data);
 360   }
 361 
 362   mlib_ImageDeleteRowTable(img);
 363   mlib_free(img);
 364 }
 365 
 366 /***************************************************************/
 367 mlib_image *mlib_ImageCreateSubimage(mlib_image *img,
 368                                      mlib_s32   x,
 369                                      mlib_s32   y,
 370                                      mlib_s32   w,
 371                                      mlib_s32   h)
 372 {
 373   mlib_image     *subimage;
 374   mlib_type      type;
 375   mlib_s32       channels;


< prev index next >