Image2Brick

Author Topic: Image2Brick  (Read 5269 times)


(Took about 5 seconds)




(Example of background color selection and background exclusion)


(Don't do this. I don't remember how long it took, but it was over 2 hours)



Cons:
  • Entirely in TorqueScript, unlike other Image2Brick mods.
  • Probably slower than other Image2Brick mods.
  • Can't close GUI, open the console, or put your mouse or practically anything else over the image while the mod is running.
  • Estimated time gets less accurate the bigger the build is.

Other things:
  • Any size image works.
  • Easily pause and resume the build.
  • Works with any brick.
  • There are small red and blue lines as X and Y indicators on the image that represent the build's progress.
  • The build starts in the lower left-hand corner and builds up/forward row by row.
  • You can click and drag on the image to resize it.
  • Optional proportional image scaling(only works with manual input, not dragging).
  • If the image has transparency, you can change the background color.
  • If you select a transparent background color, the correct transparent brick color will be selected.
  • Re-color the image in the GUI(ish).
  • You can build the image upright or flat on the ground.
  • If you select a background color and then exclude the background, then the most transparent color in the server will be selected to replace the background color(if you have it set to tall). If flat is selected then the background colored bricks won't be planted at all.

File selector module by Nexus.

The keybind to open the GUI is under Options > Controls > Building.

Happy spamming.

https://www.dropbox.com/s/6sscm425c9w930s/Client_Image2Brick.zip?dl=1
« Last Edit: June 17, 2019, 12:54:54 PM by jes00 »


how do you read image files from torquescript? does it load it as a bitmap in the game and then read the pixels?
« Last Edit: June 17, 2019, 12:50:38 PM by Dilbert »

inb4 even more people make even more research img2brick

how do you read image files from torquescript
If you make a GuiBitmapCtrl then you can get individual pixel colors from it with .getPixelColor(x, y); but the y coordinate is actually the coordinate relative to the Blockland window instead of the GuiBitmapCtrl(or something like that), so I made this function to fix it. It's also kind of trash because if the pixel is obstructed by anything(if it's something outside of the Blockland application then it's fine) then it'll get the color of the thing obstructing it.
Code: [Select]
function guiBitmapCtrl::getRealPixelColor(%obj, %x, %y)
{
%realY = -2 * getWord(%obj.getScreenPosition(), 1);
%realY += getWord(getRes(), 1) - %y;
%realY--;

return %obj.getPixelColor(%x, %realY);
}
inb4 even more people make even more research img2brick
Real images are so big that they take forever and ever to do.
« Last Edit: June 17, 2019, 12:57:59 PM by jes00 »

that's a good looking GUI right there, nice work



If you make a GuiBitmapCtrl then you can get individual pixel colors from it with .getPixelColor(x, y); but the y coordinate is actually the coordinate relative to the Blockland window instead of the GuiBitmapCtrl(or something like that), so I made this function to fix it. It's also kind of trash because if the pixel is obstructed by anything(if it's something outside of the Blockland application then it's fine) then it'll get the color of the thing obstructing it.
Code: [Select]
function guiBitmapCtrl::getRealPixelColor(%obj, %x, %y)
{
%realY = -2 * getWord(%obj.getScreenPosition(), 1);
%realY += getWord(getRes(), 1) - %y;
%realY--;

return %obj.getPixelColor(%x, %realY);
}
can't you just pop all the guis and push just the guibitmapcontrol briefly, cache the pixels and then push all the guis back?

Is this client sided?
Yes.
can't you just pop all the guis and push just the guibitmapcontrol briefly, cache the pixels and then push all the guis back?
Didn't think about doing something like that. Might work.


can't you just pop all the guis and push just the guibitmapcontrol briefly, cache the pixels and then push all the guis back?
Tried it. It would just constantly be flashing up on your screen because it would have to happen so often.

what about a image2bls

what about a image2bls
What would be the point? Just save the bricks.

Tried it. It would just constantly be flashing up on your screen because it would have to happen so often.
i dont understand why can't you just get all the pixel data and store it in a global "2d array" and then delete the globals after,
obviously not sure how fast this would be for a huge images but seems reasonable for anything like 500x500 pixels and under