vpSetImage(3)
π vpSetImage β specify an image array π
okay bestie, you're in the vpSetImage(3) page from the Library Functions Manual and honestly? this one is a slay. it's the function that tells VolPack where to put the picture. let's get into it π
β¨ NAME β¨
vpSetImage β specify an image array. that's it, that's the whole vibe π
πΈ SYNOPSIS πΈ
#include <volpack.h>
vpResult
vpSetImage(vpc, image, width, height, scan_bytes, pixel_type)
vpContext *vpc;
unsigned char *image;
int width, height;
int scan_bytes;
int pixel_type;
π¦ ARGUMENTS π¦
vpcβ the VolPack context, the one you got fromvpCreateContext. your main character.imageβ a 2D array that's gonna hold the result images. the canvas, the moment, the whole point π¨widthβ width of the image, in pixels.heightβ height of the image, in pixels.scan_bytesβ how many bytes there are per scanline in theimagearray.pixel_typeβ a code that says what the format of each pixel in the array is.
π DESCRIPTION π
vpSetImage is how you hand over a buffer for storing the result image while rendering happens. the width and height params set the size of that result image, and β important β the clipping window (peep vpWindow(3) or vpWindowPHIGS(3)) gets scaled to match that size exactly. no notes. π―
the scan_bytes argument is the size of a scanline in the image array, in bytes. why would you ever need that, you ask? because you can use it to add padding to the end of each scanline so alignment restrictions are satisfied β like, raster operations sometimes need the beginning of every scanline to land on a word boundary. it's giving "i need my space" π«Ά
the pixel_type argument says what format a pixel is in. here are all the formats that are supported, no cap:
VP_ALPHAβ each pixel is one byte and holds an 8-bit alpha channel (so, an opacity or coverage value for that pixel).VP_LUMINANCEβ each pixel is one byte and holds an 8-bit grayscale intensity.VP_LUMINANCEAβ each pixel is two bytes: an 8-bit grayscale intensity first, then an 8-bit alpha channel.VP_RGBβ each pixel is three bytes and holds an RGB color (8 bits/channel). R is stored first, then G, then B.VP_RGBAβ each pixel is four bytes and holds an RGBA color with an alpha channel (8 bits/channel). R goes first, then G, then B, then A.VP_BGRβ each pixel is three bytes and holds an RGB color (8 bits/channel). B is stored first, then G, then R.VP_ABGRβ each pixel is four bytes and holds an RGBA color with an alpha channel (8 bits/channel). A goes first, then B, then G, then R.
now, the rules of who can hang with whom (very much a vibe check situation):
VP_LUMINANCEandVP_LUMINANCEAare only allowed with grayscale shaders. that means thecolor_channelsargument tovpSetLookupShaderhas to be1, or β if you're using a callback function for shading β you have to use theVP_GRAY_SHADE_FUNCargument tovpSetCallback.VP_RGB,VP_RGBA,VP_BGRandVP_ABGRare only allowed with color shaders.VP_ALPHAis the flexible icon and can be used with either type of shader. she contains multitudes β¨
the size of the image array has to be:
unsigned char image[height][scan_bytes];
and scan_bytes must be at least width times the number of bytes per pixel. pixels inside a horizontal scanline are packed right next to each other, no matter what size the pixel is. any extra padding bytes hanging out at the end of a scanline? not modified. untouched. left alone. π
okay and the alpha channel? she's the moment for compositing your rendered image against a background image. alpha gives you the fraction of the background that's visible through the rendered image β 0 means fully visible, 255 means fully obscured. so like, say you wanna change the background color of the image to a solid color C: you modify the color of every pixel in the image according to this formula:
color(x,y) += C * (1 - alpha(x,y)/255)
slay. math ate. π₯
π STATE VARIABLES π
you can pull the current image array properties back out with these state variable codes (check vpGeti(3)): VP_IMAGE, VP_IMAGE_WIDTH, VP_IMAGE_HEIGHT, VP_IMAGE_SCAN_SIZE, VP_PIXEL_TYPE.
π ERRORS π
the return value is always VP_OK. yes, always. the drama is nonexistent, she's stable, she's unbothered. π
π SEE ALSO π
VolPack(3), vpCreateContext(3), vpRenderRawVolume(3)
that's the whole page bestie, go render something gorgeous π this one came from the VolPack source, and yeah β it's vpSetImage(3) all the way down. byeee, love u, drink water πΈ
π¦ where this page comes from
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- Copyright (c) 1995-2008, Stanford University
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms