! . */
| 682 | |
| 683 | /*! . */ |
| 684 | GMT_LOCAL int gmtapi_alloc_image (struct GMT_CTRL *GMT, uint64_t *dim, unsigned int mode, struct GMT_IMAGE *I) { |
| 685 | /* Use information in Image header to allocate the image data. |
| 686 | * We assume gmtapi_init_grdheader has been called. |
| 687 | * If dim given and is 2 or 4 then we have 1 or 3 bands plus alpha channel |
| 688 | * Depending on mode, the alpha layer is part of image or separate array. */ |
| 689 | unsigned int n_bands = I->header->n_bands; |
| 690 | struct GMT_IMAGE_HIDDEN *IU = NULL; |
| 691 | |
| 692 | if (I == NULL) return (GMT_PTR_IS_NULL); |
| 693 | if (I->data) return (GMT_PTR_NOT_NULL); |
| 694 | if (I->header->size == 0U) return (GMT_SIZE_IS_ZERO); |
| 695 | IU = gmt_get_I_hidden (I); |
| 696 | if (dim && (dim[GMT_Z] == 2 || dim[GMT_Z] == 4)) { /* Transparency layer is requested */ |
| 697 | if ((mode & GMT_IMAGE_ALPHA_LAYER) == 0) { /* Use a separate alpha array */ |
| 698 | if ((I->alpha = gmt_M_memory_aligned (GMT, NULL, I->header->size, unsigned char)) == NULL) return (GMT_MEMORY_ERROR); |
| 699 | n_bands--; /* One less layer to allocate */ |
| 700 | } |
| 701 | } |
| 702 | if ((I->data = gmt_M_memory_aligned (GMT, NULL, I->header->size * n_bands, unsigned char)) == NULL) return (GMT_MEMORY_ERROR); |
| 703 | I->header->n_bands = n_bands; /* Update as needed */ |
| 704 | IU->alloc_mode = GMT_ALLOC_INTERNALLY; /* Memory can be freed by GMT. */ |
| 705 | IU->alloc_level = GMT->hidden.func_level; /* Must be freed at this level. */ |
| 706 | return (GMT_NOERROR); |
| 707 | } |
| 708 | |
| 709 | /*! . */ |
| 710 | GMT_LOCAL double * gmtapi_image_coord (struct GMTAPI_CTRL *API, int dim, struct GMT_IMAGE *I) { |
no test coverage detected