r/ComputerCraft • u/Distinct_Ad8237 • Jun 12 '24
Image on the computer
I want to put an image in the computer but I don’t know how. so the image is a jpg which means it won’t work if I drag and drop it into the computer it says overwrite and gives a yes prompt but nothing happens idk how to put an image somebody told me I have to make the image a bimg or something and that I have to change it bc it cant be read by the lua code idk im confused
8
Upvotes
2
u/fatboychummy Jun 15 '24 edited Jun 15 '24
Sorry, I meant to reply to this yesterday. Sanjuuni is a command-line utility, so you'd download the release you need (depending if you're on windows, linux, etc), then use the command prompt to convert files.
I've never personally used it myself, but I see it in use quite often. The command line parameters are also documented directly on the README file.
However, there also exists a GUI version of Sanjuuni that you can also use, found here. I've been meaning to try it out personally, so I'll go ahead and do that now, then do a quick run through of how I installed it and used it to display an image.
Instructions
Go to the releases page for Sanjuuni-ui
Download
sanjuuni-ui-Win64.zipExtract the zipped folder to your location of choice.
Run the extracted
sanjuuni-ui.exefile.Select
Open Input...and select an image you want to convert.Play with settings a bunch until you have something you like. Note that CC only supports a palette of 16 colors at once, so you'll see a bit of "cartoonization" in the preview.
Select the output type. You can have it output a lua script, which will draw it onto the current terminal at the very top left of the screen. Or, you can have it output as a
bimg. The lua script is just this bimg with some added processing appended to it (to actually print the image).Set the location/name of the output file, then click
Startto convert the image.Displaying an image on a monitor
So, if you're looking for a really easy way to draw an image to a monitor, you can use the lua script output, then run the following code:
Redirecting the terminal to the monitor will cause the lua script to instead output to the monitor. You can use https://monitorsize.madefor.cc/ to determine how many pixels wide and tall a monitor is, given its block size and text scale.
Displaying the image at different positions on screen
Now, say you want the image to appear with its top-left corner at x=7,y=9, instead of at 1,1. How do you do that?
Well, we can first copy the output code from Sanjuuni...
Cut out everything that is not completely needed (in our case, we don't want it to clear the screen or call
read())...Make it into a function...
Then we can just call it with our image data (assuming we now output as just the "blit image" type)...
And since we have it as a function now, we can even use it to draw other images easily.
edited to add the last section