resample_image(3)

πŸ“¦
version 0.7.1 Β· 2 versions
, in nixos 26.05

πŸŽ€ resample_image β€” Arcan Lua API πŸŽ€

okay bestie, this is the resample_image(3) page from the Arcan Lua API, and it's literally the β€œscale an image to new dimensions using a shader” function. It's giving off-screen pass energy, and we're gonna go through every form, every note, and both extremely cursed misuse examples, no cap. πŸ’…βœ¨

✨ NAME ✨

resample_image β€” scale an image to new dimensions using a shader. That's the whole pitch: textured object goes in, shader says how to resample, new width/height comes out. 🌈

🧚 SYNOPSIS 🧚

okay so the synopsis starts with nil, then gives you three call shapes β€” pick your fighter, bestie:

       nil
       resample_image( vid:src, shid:shader, int:width, int:height,
       bool:nosynch )
       resample_image( vid:src, shid:shader, int:width, int:height, vid:dst )
       resample_image( vid:src, shid:shader, int:width, int:height, vid:dst,
       bool:nosynch )

πŸ’– DESCRIPTION πŸ’–

This function takes the textured object referenced by src and resamples it to width and height output using the shader specified in shader. So src is the textured object, shader is the glow-up recipe, and width/height are the new dimensions. slay. 🌟

If you use the second argument form, the backing store of dst will be replaced with the resampled output rather than the backing store of src. Translation: dst gets the new hotness, not src. πŸ’…

If the nosynch argument is specified (default to false), the local memory copy of the backing store will be ignored. That means the backing can't be reconstructed if the engine suspends to an external source, which might lead to the data being lost β€” or the time to suspend increases to account for creation of the local copy. So yeah, be careful with that one. ⚠️

πŸ“ NOTES πŸ“

  1. The resampled storage is subject to the same limitations as other image functions that create a storage buffer, exceeding MAX_SOURCEW , MAX_SOURCEH is a terminal state transition. Like, terminal terminal β€” no coming back, bestie. πŸ’€
  2. This function internally aggregates several regular calls into one and presented here more for a convenience use of a complex setup. The flow can be modeled as:
    1. create temporary renderbuffer with a temporary output and a null object reusing the storage in vid.
    2. apply shader, do an off-screen pass into the renderbuffer.
    3. switch glstore from temporary into vid, readback into local buffer and update initial state values (width, height, ..).

🌸 EXAMPLE 🌸

here's the normal example β€” yes, the shader function is literally also named resample_image0, we love consistency:

       function resample_image0()
             local img = load_image("test.png");
             local shid = build_shader(nil, [[
       uniform sampler2D map_diffuse;
       varying vec2 texco;
       void resample_image0()
       {
             vec4 col = texture2D(map_diffuse, texco);
             gl_FragColor = vec4(1.0, col.g, col.b, 1.0);
       }
       ]], "redscale");
             resample_image(img, shid, 640, 480);
             show_image(img);
       end

πŸ’€ MISUSE πŸ’€

this first misuse is the β€œnegative dimensions” moment: resample_image(img, shid, -64, -64); β€” bestie, why 😭. The manual files it under MISUSE, so that's your warning:

       function resample_image0()
             local img = load_image("test.png");
             local shid = build_shader(nil, [[
       uniform sampler2D map_diffuse;
       varying vec2 texco;
       void resample_image0()
       {
             vec4 col = texture2D(map_diffuse, texco);
             gl_FragColor = vec4(1.0, col.g, col.b, 1.0);
       }
       ]], "redscale");
             resample_image(img, shid, -64, -64);
       end

πŸ’€ MISUSE πŸ’€

and this second misuse goes big-big: resample_image(img, shid, 6400, 4800);. Again, filed under MISUSE in the manual β€” do not treat this as a cute suggestion. πŸ™ˆ

       function resample_image1()
             local img = load_image("test.png");
             local shid = build_shader(nil, [[
       uniform sampler2D map_diffuse;
       varying vec2 texco;
       void resample_image1()
       {
             vec4 col = texture2D(map_diffuse, texco);
             gl_FragColor = vec4(1.0, col.g, col.b, 1.0);
       }
       ]], "redscale");
             resample_image(img, shid, 6400, 4800);
       end

πŸ”— SEE ALSO: πŸ”—

  • image

with love from the image source/version, dated <month>October 2026</month> β€” resample_image(3) πŸ’–πŸ«Ά

πŸ“¦ where this page comes from