Skip to content

Instantly share code, notes, and snippets.

@kalwalt
Created April 23, 2024 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalwalt/fa0fadaa6df90a9ad8b87058b1e950f2 to your computer and use it in GitHub Desktop.
Save kalwalt/fa0fadaa6df90a9ad8b87058b1e950f2 to your computer and use it in GitHub Desktop.
test with Vector type instead of Array (Virgil)
def imgProc_gray(width: int, height: int, channels: u8, inputData: Pointer) -> Pointer {
var imgProc = ImgProc.new(width, height, channels);
var inputData_size = width * height * channels;
var internal_data: Vector<byte> = Vector<byte>.new();
for (i = 0; i < inputData_size; i++) {
internal_data[i] = (inputData + i).load<byte>();
}
return Pointer.atContents(imgProc.grayscale(internal_data));
}
/*
// This is the error with the Vector version
./build.sh
[FiltersWasm.v3 @ 29:30] TypeError: cannot infer type parameter T of "atContents"
return Pointer.atContents(imgProc.grayscale(internal_data));
^
[FiltersWasm.v3 @ 29:31] TypeError: call requires type Range<?> and found Vector<byte>
return Pointer.atContents(imgProc.grayscale(internal_data));
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment