lua: Make frame:getPixel return three values

This is what users will want in the majority of cases, and switching
to this makes using this function much easier.

However, this does break backwards compatibility. Luckily to my
knowledge this function is not actually used in any existing published
script (all scripts using get_frame just use getPixelFormatted instead)
so the damage shouldn't be too large. But this is also why I'd rather
rip off the band-aid of breaking backwards compatibility now than later.
This commit is contained in:
arch1t3cht 2024-02-17 02:22:23 +01:00
parent c11f17b9e6
commit 63bbdc32d3
2 changed files with 9 additions and 6 deletions

View File

@ -40,7 +40,7 @@ Returns: number
Get RGB pixel value at a certain position of frame object.
function frame:frame:getPixel(x, y)
function frame:getPixel(x, y)
@x (number)
Pixel to retrieve on the x-axis
@ -48,8 +48,10 @@ function frame:frame:getPixel(x, y)
@y (number)
Pixel to retrieve on the y-axis
Returns: number
Integer value representing the RGB pixel value.
Returns: 3 values, all numbers
1. R value of the pixel
2. G value of the pixel
3. B value of the pixel
---

View File

@ -230,12 +230,13 @@ namespace {
size_t pos = y * frame->pitch + x * 4;
// VideoFrame is stored as BGRA, but we want to return RGB
int pixelValue = frame->data[pos+2] * 65536 + frame->data[pos+1] * 256 + frame->data[pos];
push_value(L, pixelValue);
push_value(L, frame->data[pos+2]);
push_value(L, frame->data[pos+1]);
push_value(L, frame->data[pos]);
} else {
lua_pushnil(L);
}
return 1;
return 3;
}
int FramePixelFormatted(lua_State *L) {