vpSetImage(3)
π vpSetImage(3) π
okay bestie, gather round, because this is the one that tells VolPack where to actually put your pretty pictures. it's a Library Functions Manual entry, it's from VolPack, and it's lowkey one of the most important calls you'll make. no cap.
β¨ NAME β¨
vpSetImage β specify an image array π
πΈ 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 you got fromvpCreateContext. your main character, basically.imageβ a 2D array where the result images get stored. this is the canvas, bestie. π¨widthβ how wide the image is, in pixels.heightβ how tall the image is, in pixels.scan_bytesβ how many bytes each scanline takes up in theimagearray.pixel_typeβ a code that says what format every pixel in the array is in.
π DESCRIPTION π
vpSetImage is the call that hands VolPack a buffer to stash the result image in while it's rendering. the width and height params set the size of that result image, and β this is the part that matters β the clipping window (peep vpWindow(3) or vpWindowPHIGS(3)) gets scaled to match that size exactly. so like, whatever you set here is the vibe the clip window is gonna serve. β¨
the scan_bytes argument is the size of a scanline in the image array, measured in bytes. why would you want that separate from width? padding, babe. you can add padding to the end of each scanline to satisfy alignment restrictions β like, raster operations sometimes need the start of every scanline to land on a word boundary, and this is how you make that happen. π
the pixel_type argument says what format a pixel is in. here are the formats that are supported, and yes, we're doing all of them:
VP_ALPHAβ every pixel is one byte and holds an 8-bit alpha channel (an opacity or coverage value for that pixel).VP_LUMINANCEβ every pixel is one byte and holds an 8-bit grayscale intensity.VP_LUMINANCEAβ every pixel is two bytes: an 8-bit grayscale intensity first, then an 8-bit alpha channel.VP_RGBβ every pixel is three bytes and holds an RGB color (8 bits per channel). R goes first, then G, then B.VP_RGBAβ every pixel is four bytes and holds an RGBA color with an alpha channel (8 bits per channel). R goes first, then G, then B, then A.VP_BGRβ every pixel is three bytes and holds an RGB color (8 bits per channel). B goes first, then G, then R.VP_ABGRβ every pixel is four bytes and holds an RGBA color with an alpha channel (8 bits per channel). A goes first, then B, then G, then R.
now, the shader tea β β this part is a whole vibe check:
VP_LUMINANCEandVP_LUMINANCEAcan only be used with grayscale shaders. that means thecolor_channelsargument tovpSetLookupShaderhas to be1, or, if you're shading with a callback function, you gotta use theVP_GRAY_SHADE_FUNCargument tovpSetCallback.VP_RGB,VP_RGBA,VP_BGRandVP_ABGRcan only be used with color shaders.VP_ALPHAis the flexible icon and can be used with either type of shader. π
the size of the image array has to be:
unsigned char image[height][scan_bytes];
and the scan_bytes argument must be at least width times the number of bytes per pixel. pixels in 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 are not modified β so don't come for them, they're minding their business. π
the alpha channel is what lets you composite the rendered image against a background image. alpha is the fraction of the background that's visible through the rendered image β 0 means fully visible, 255 means fully obscured. for example, to change the background color of the image to a solid color C, you modify the color of each pixel in the image using this formula:
color(x,y) += C * (1 - alpha(x,y)/255)
β STATE VARIABLES β
you can retrieve the current image array properties with these state variable codes (check vpGeti(3) for the deets): VP_IMAGE, VP_IMAGE_WIDTH, VP_IMAGE_HEIGHT, VP_IMAGE_SCAN_SIZE, VP_PIXEL_TYPE.
π ERRORS π
the return value is always VP_OK. literally always. it's giving unbothered. it's giving no notes. π
π«Ά SEE ALSO π«Ά
VolPack(3), vpCreateContext(3), vpRenderRawVolume(3)
and that's the whole page, bestie!! π you now know exactly how to hand VolPack an image buffer, so go forth and render something iconic. this has been a VolPack manual moment, courtesy of VolPack itself β mwah, slay, periodt. πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: libvolpack1-dev 1.0b3-9 Β· BSD-3-Clause
- debian trixie: libvolpack1-dev 1.0b3-10 Β· BSD-3-Clause
- ubuntu jammy: libvolpack1-dev 1.0b3-9 Β· BSD-3-Clause
- ubuntu noble: libvolpack1-dev 1.0b3-9.1 Β· BSD-3-Clause
- ubuntu questing: libvolpack1-dev 1.0b3-11
- ubuntu resolute: libvolpack1-dev 1.0b3-11build1 Β· BSD-3-Clause
- ubuntu stonking: libvolpack1-dev 1.0b3-11build1 Β· BSD-3-Clause
- Copyright (c) 1994 The Board of Trustees of The Leland Stanford
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms