vpGetImage(3)

πŸ“¦ version 1.0c7, in fedora 43, fedora 44

πŸ’– vpGetImage(3) πŸ’–

okay so bestie, we're in section 3 of the VolPack Library Functions Manual today and the vibe is debugging, so buckle up πŸŽ€


✨ NAME ✨

vpGetImage β€” grab yourself a field of the intermediate image πŸ‘€


🌸 SYNOPSIS 🌸

#include <volpack.h>

vpResult
vpGetImage(vpc, image, width, height, scan_bytes, pixel_type,
        image_type)
    vpContext *vpc;
    void *image;
    int width, height;
    int scan_bytes;
    int pixel_type, image_type;

πŸ¦‹ ARGUMENTS πŸ¦‹

  • vpc β€” the VolPack context you got from vpCreateContext. your main character 🫢
  • image β€” a 2D array where the result image gets stored. it's the canvas, she's ready πŸ’…
  • width β€” how wide the array is, in pixels.
  • height β€” how tall the array is, in pixels.
  • scan_bytes β€” how many bytes there are per scanline in the array.
  • pixel_type β€” a code saying what format each pixel in the array is in.
  • image_type β€” a code saying where the image data is coming from: either VP_IMAGE_BUFFER or VP_SHADOW_BUFFER.

🌈 DESCRIPTION 🌈

so this one is a debugging function, periodt. what she does is pull the contents of one of the temporary rendering buffers that get used during rendering β€” specifically the intermediate image or the shadow buffer.

let's talk about how rendering works here, because it's literally two stages:

  1. the volume gets resampled and composited into the intermediate image, which gives you a distorted volume rendering ✨
  2. then the intermediate image gets warped into the final image πŸ’«

and if shadows are turned on, the shadow buffer is used during that first stage to incrementally compute which voxels are lit up by the light source. so this function gives you the images from the first stage, before the final warp even happens. no cap.

you can call this after one of the rendering routines (peep vpRenderRawVolume(3) for that).

  • if image_type is VP_IMAGE_BUFFER, data gets copied out of the intermediate image.
  • if image_type is VP_SHADOW_BUFFER, data gets copied out of the shadow buffer.

the pixel_type argument says what info to copy and what format to store it in inside the output array. the valid values for pixel_type are the exact same ones as for the pixel_type argument to vpSetImage. for example, use VP_LUMINANCE to extract the grayscale intensity (that's assuming your current shader is producing grayscale pixels, bestie 🌸).

⚠️ heads up: when image_type is VP_SHADOW_BUFFER, the only valid option for pixel_type is VP_ALPHA, because there's no color information stored in the shadow buffer at all. so don't try it, she won't play πŸ’€

for the deets on pixel formats, the layout of the output array, and the rest of the arguments β€” go read vpSetImage.

and to figure out how big your result array needs to be, use vpGeti with:

  • VP_INTERMEDIATE_WIDTH and VP_INTERMEDIATE_HEIGHT when image_type is VP_IMAGE_BUFFER
  • VP_SHADOW_WIDTH and VP_SHADOW_HEIGHT when image_type is VP_SHADOW_BUFFER

😭 ERRORS 😭

the normal return value is VP_OK β€” she ate, no notes πŸ‘‘

these are the error return values that can show up:

  • VPERROR_BAD_SIZE β€” the destination array size is wrong, or there's just no intermediate image to speak of. πŸ™ˆ
  • VPERROR_BAD_OPTION β€” the field argument is invalid. 🚫

πŸ‘‘ SEE ALSO πŸ‘‘

VolPack(3), vpRenderRawVolume(3), vpGeti(3)


and that's the whole page, bestie 🫢 this one comes to you courtesy of VolPack and lives at vpGetImage(3). no date on this one, so consider this your timeless lil sign-off πŸŽ€βœ¨

πŸ“¦ where this page comes from