Which platform? Pico-8? Tic-80? Something else?
I was searching for a similar thing for Tic-80 and found these, but I haven’t tried it yet:
https://github.com/nesbox/TIC-80/wiki/code-examples-and-snippets#setget-spritesheet-pixel
https://github.com/nesbox/TIC-80/wiki/spr (first code example starting with -- spr demo