PB2IMG2 (Add any image to your maps!)

Tutorials and guides for Plazma Burst and community features.

PB2IMG2 (Add any image to your maps!)

Postby phsc » 20 November 2020, 09:37

Around a year ago, I published this, viewtopic.php?f=126&t=23117
But that program was bad! it had performance problems, was extremely laggy during the insert of the image, in the editor and ingame, so I remade it in an actual good way, with 1041 lines of code, I present you all PB2IMG2, a program that inserts images into the Plazma Burst 2 editor.



Download: https://phscdev.com/files/PB2IMG2.exe

At first the program can be somewhat confusing, so this is a tutorial on what everything does:

EXPLANATION OF THE INTERFACE:
Spoiler: Show More
SELECT IMAGE allows you to select a image, and create them, using generic windows libraries, and adds their location to the text box on it's side, you can also put the direct file location on that text box.
The same goes for SELECT PB2 XML, it allows you to select the XML or even any text file, and puts it's location there.
INSERT IMAGE inserts the image, however some fields must not be blank, such being the SELECT IMAGE and SELECT PB2 XML text boxes, the pixel x size, the pixel y size, the background (selected by default) and the X and Y position fields.
PIXEL X SIZE and PIXEL Y SIZE are the size of each individual pixel as a PB2 background, 10 is the average square you see in the level editor, and is the standard value.
X POSITION and Y POSITION are the starting positions for the image, starting always top left, think of the default PB2 coordinate system, positive values go down and to the right, it starts at 0 and just adds to it.
X OFFSET and [b]Y OFFSET[/b] are the offsets for the backgrounds, if for some reason you want to do that.
BACKGROUND is the background that will be used, White is the default one selected.
ATTACH TO is an object you can attach the backgrounds too, you have to take it's exact name and put it there.
DRAW IN FRONT sets the backgrounds that make up the image to draw in front.
SPAWN SHADOWS by default does nothing, because shadows spawn by default, but if you disable it, it disables shadows.
CHECK FOR ALPHA LAYER checks for the alpha value in the individual pixel being checked for the image, this means the ones that are not a perfect pixel, so A != 255, are not inserted, unless you are adding an image that fits the whole file, keep this checked, it is also very inneficient at inserting images with values that are not 0 and 255 (because PB2 does not have an alpha value for backgrounds) and it instead of adding a black background at the back, will insert it at the sides, I made that like that for testing purposes and in the future it is likely to change.
PREVIEW XML previews the XML code of the file in that text box near the SAVE XML FILE button, for bigger files, reading the text file into that text box can take some time, so disable it, but for smaller ones that can be more useful, since you can directly insert it into latest save browser memory, or just manually add to a map, maybe at a specific point to set up the layers as you want.
PREVIEW IMAGE is pretty much the same but for the image file, for bigger images I'd keep it closed, but the performance impact is very small, and you should not be inserting extremely big images, because PB2 can barely handle them.
SAVE XML FILE saves the content of the XML text box into the file under the SELECT PB2 XML text box, this is very useful if you want to clear the file there, or if you want to check if the insertion went right if you know what you are doing.
The X and Y bars are the progress when inserting the image, the grey field on their right shows the X and Y dimensions of the image.

INFORMATION ON INSERT METHODS:

Spoiler: Show More
Generally speaking, images always start from the left top part of your monitor, just like coordinates work
in PB2, and generally checking the Y value (going from 0 to the max value) before, and then checking the X value, and repeats, two while/for/etc loops, while (x<xtotal) and inside of that while(y<ytotal)
BASIC simply gets the pixel, checking all Y values, then the X values, and simply creates a background for them, this runs pretty damn fast, since all methods do check literally all pixels at least once (some are faster than others because pixels inserted are not checked), this does not have this, so for images that are extremely effective for other insert methods, this can be pretty slow when compared to, but the biggest issue is the file size,
VERTICAL checks every single individual pixel, Y then X, and checks if the pixel that is under it, if it is the same color, if it is, then it adds a single background increasing the Y dimension, until it cannot, then it goes to the next pixel, this has more to check for, so it is slower than the basic insert, but if it does cover more pixels, you have to check less, so it ends up being faster at times, but it does run way faster ingame, since it pretty much has half of the objects than normal inserts generally, you can also posterize images to make it faster and more effective.
LATERAL is pretty much the same as vertical but lateral, checks all pixels, Y then X and such, if the one to the right side has the same colors and such, it adds a single background to cover multiple pixels.
ONE DIMENSIONAL X will run both vertical and lateral to see which is bigger, and insert the bigger one, this is where X and Y priority come in, the most effective way is simulating all priorities and all basic start directions, but that gets really heavy to insert images with, it takes a lot of time, and currently the program does not run with a graphics card, I will talk more about that later but, this will take the biggest insert possible for either X and Y, and this one checks Y then X.
ONE DIMENSIONAL Y is the same as one dimensional X but with Y priority, so it checks for X then Y, in a general way, this matters little, but there is an image difference in object amount, very small, but still there.
TWO DIMENSIONAL XX will check Y then X for each individual pixel, and inside of each single check, it will move the pixel box to the right and down, to see if it can be bigger, and if it fits, it inserts it with the dimensions to fit the area checked, this is by far the most effective method, not always because there are three other two dimensional inserts, anyways, should it check to the right or down first? and this is what the second value defines, X means X has priority, so side checks first, and then Y, this can take a while if it does not find many places to insert in effective ways, posterizing really helps.
TWO DIMENSIONAL XY is the same as TWO DIMENSIONAL XX but it checks Y then X, while(x) while(y).
TWO DIMENSIONAL YX is pretty much the same as the other two above, but it will check X then Y for individual pixels, and then Y and X for checking similar colors.
TWO DIMENSIONAL YY should be fairly obvious, checks Y then X, and checks Y then X for the color check, that is it.
SIMULATION 1D/2D run all the methods for each insert method, and actually I plan on adding a feature where they will also run them coming from other sides, currently disabled because they take an absurd amount of time, I will explain more about them later.

TLDR: BASIC is fast to insert (sometimes) but lags a lot ingame because a ton of objects
VERTICAL and LATERAL check pixels that have the same colors, vertically and laterally, and makes backgrounds bigger based on that.
ONE DIMENSIONAL X and Y do the same as the above, but they check what insertion is more effective, and which should run if both are equally effective, with priority for vertical inserts (Y) or lateral ones (X).
TWO DIMENSIONAL inserts will run both X and Y, they will go down and to the side and try to fit, they take way longer to insert, but should literally always be the most effective ones inside of a PB2 map.

Some tips:
1 - Do not insert images that are too big, mostly if you use BASIC as the insert method, every pixel might generate a background, that means <bg x="X" y = "Y" w="X" h="Y" m="X" c="#XXXXXX" /> gets added to the map file, this for every single pixel in BASIC, and a few less depending on the image you add, this means that PB2 has a lot of data to read, a 200 by 200 pixels image means 40000 objects if you use BASIC, a 500 by 500 one means 250000.
2 - Lag is not the problem! I mean, in the level editor it will lag, but ingame it might run fine, the issue is loading times, it is a lot of text, and that might make the map unable to load in time! keep that in mind.
3 - Posterizing the image, that is making similar colors one single color, greatly increases how effective inserting the image is with other methods, mostly the TWO DIMENSIONAL ones, remember that!
4 - Disble the XML preview for big images, or if your computer is slow, since loading the XML file there can take a while.
5 - Every added field means more text! which means longer load time! X offsets, attaching, not spawning shadows and drawing in front can add a lot of text, keep that in mind! it can even double a single pixel's size.

In the future I play on updating this program, allowing the 1D and 2D simulation inserts, and the simulation preview (show how PB2 would read the XML file as an image), but that will come in version 2.1 of PB2IMG, I will also make so things can run using the GPU.
Also, if you are unsure, this does run on Linux (tested on Artix), I am unsure if this runs on Mac, any issuses let me know!

IMPORTANT NOTE: What you do with this program is up to you, if you put images that break the code of conduct and such, you can get banned, if you see anyone abusing this program or breaking the code of conduct with it, report to staff members.
Last edited by phsc on 29 November 2020, 12:35, edited 2 times in total.
User avatar
phsc
Noir Lime [600]
 
Posts: 694
Joined: 27 July 2013, 13:58
Location: Brazil

Re: PB2IMG2 (Add any image to your maps!)

Postby Build » 21 November 2020, 01:25


Short video showcasing the img program.
User avatar
Build
Falkok [250]
 
Posts: 275
Joined: 27 February 2018, 18:18
Location: Backrooms

Re: PB2IMG2 (Add any image to your maps!)

Postby yi en » 21 November 2020, 05:27

the whole forum post has been copied to the manual.
Page: https://eagleforceleader.gitbook.io/pb2 ... map-source

and I have added some actual results of all modes inside that manual too.
User avatar
yi en
Civil Security Boss [500]
 
Posts: 556
Joined: 20 August 2013, 09:10
Location: What do you need, then?

Re: PB2IMG2 (Add any image to your maps!)

Postby phsc » 29 November 2020, 12:31

The program has been updated, it now includes the MULTILAYER 2D XX insert method, which is the XX one that simply makes the image as big as it can be considering the insertion method, instead of stopping when there is a different pixel, it will continue, of course it is limited by the alpha channel, but you can always uncheck that.

The original download link is already updated, if you for some reason want version 2.0 instead of 2.1, you can use https://phscdev.com/files/PB2IMG2.0.exe and I also deleted the installer version because it is just useless and annoying to update.

Some images of how the new inserts work:
2D XX:


2D XX MULTILAYER:


Generally speaking, performance-wise in the level editor it should lag less as in updating objects and selection times, but visual renderization should be a bit worse, insert time should be increased since I had to move one of the condition checks to another loop which runs more, but the other condition checks are smaller as well, but since there are fewer pixels to check, it should be fairly similar, faster for images with a ton of pixels of the same color, mostly if in the background, and slower for images where that is not the case.
User avatar
phsc
Noir Lime [600]
 
Posts: 694
Joined: 27 July 2013, 13:58
Location: Brazil

Re: PB2IMG2 (Add any image to your maps!)

Postby xElijah » 29 November 2020, 15:35

Finally I can add naked anime girls to my maps. Thank you.
User avatar
xElijah
Usurpation Soldier [50]
 
Posts: 96
Joined: 3 October 2020, 15:43

Re: PB2IMG2 (Add any image to your maps!)

Postby phsc » 29 November 2020, 16:22

xElijah wrote:Finally I can add naked anime girls to my maps. Thank you.

As much as I interpret this as a light-hearted joke, this could be criticism towards the program and how it can be abused, and yes, it can be abused, just like the level editor can be, it just makes it easier for people to add anything to PB2, mostly things that are not accepted, this is good since you can insert fancy background patterns, pixelart, in general all of that stuff, without needing to make them decors, which works since decors generally have to be PB2 related, this program is essential to me at least, and yes, you can abuse it to insert pornography or whatever into the game, but you can actually quite easily do that manually if you have knowledge about how to modify the level editor and most importantly how to change the gridsnapping, and of course you can just pull the basic girl-sex move and create an innapropriate map without backgrounds and such.
There is no way for me to verify what is inserted (actually there is but it is completely not practical and it would make the program kinda like living hell and still it could be abused, not to mention how others could make a program like this) but that is what the staff team is for after all.
User avatar
phsc
Noir Lime [600]
 
Posts: 694
Joined: 27 July 2013, 13:58
Location: Brazil

Re: PB2IMG2 (Add any image to your maps!)

Postby xElijah » 29 November 2020, 16:33

phsc wrote:As much as I interpret this as a light-hearted joke, this could be criticism towards the program and how it can be abused, and yes, it can be abused, just like the level editor can be, it just makes it easier for people to add anything to PB2, mostly things that are not accepted, this is good since you can insert fancy background patterns, pixelart, in general all of that stuff, without needing to make them decors, which works since decors generally have to be PB2 related, this program is essential to me at least, and yes, you can abuse it to insert pornography or whatever into the game, but you can actually quite easily do that manually if you have knowledge about how to modify the level editor and most importantly how to change the gridsnapping, and of course you can just pull the basic ******** move and create an innapropriate map without backgrounds and such.
There is no way for me to verify what is inserted (actually there is but it is completely not practical and it would make the program kinda like living hell and still it could be abused, not to mention how others could make a program like this) but that is what the staff team is for after all.

It was a joke. Nice program. You can verify what is inserted?
User avatar
xElijah
Usurpation Soldier [50]
 
Posts: 96
Joined: 3 October 2020, 15:43

Re: PB2IMG2 (Add any image to your maps!)

Postby phsc » 29 November 2020, 16:40

xElijah wrote:
phsc wrote:As much as I interpret this as a light-hearted joke, this could be criticism towards the program and how it can be abused, and yes, it can be abused, just like the level editor can be, it just makes it easier for people to add anything to PB2, mostly things that are not accepted, this is good since you can insert fancy background patterns, pixelart, in general all of that stuff, without needing to make them decors, which works since decors generally have to be PB2 related, this program is essential to me at least, and yes, you can abuse it to insert pornography or whatever into the game, but you can actually quite easily do that manually if you have knowledge about how to modify the level editor and most importantly how to change the gridsnapping, and of course you can just pull the basic ******** move and create an innapropriate map without backgrounds and such.
There is no way for me to verify what is inserted (actually there is but it is completely not practical and it would make the program kinda like living hell and still it could be abused, not to mention how others could make a program like this) but that is what the staff team is for after all.

It was a joke. Nice program. You can verify what is inserted?

Well, I can upload it online and use external services(I am unsure how this works) to detect the content of the image, or I could take the algorithms used to check the image and apply them in my own servers or maybe on the program itself, and I could train object recognition with deep learning, however I do not have the resources to train something that complicated and it all would have to be online and of course it is a complicated task (good thing is that I have experience with machine learning and related and this is actually the field I kind of specialize in?) but it is extremely far from being practical, and of course, it can always fail and/or be abused, some weeks ago I saw porn ads on Youtube because they found a way to bypass their detection system using some unconventional images which us humans perceive as sexual content but they are far from what was used in the training of their systems.
User avatar
phsc
Noir Lime [600]
 
Posts: 694
Joined: 27 July 2013, 13:58
Location: Brazil

Re: PB2IMG2 (Add any image to your maps!)

Postby xElijah » 29 November 2020, 16:54

phsc wrote:Well, I can upload it online and use external services(I am unsure how this works) to detect the content of the image, or I could take the algorithms used to check the image and apply them in my own servers or maybe on the program itself, and I could train object recognition with deep learning, however I do not have the resources to train something that complicated and it all would have to be online and of course it is a complicated task (good thing is that I have experience with machine learning and related and this is actually the field I kind of specialize in?) but it is extremely far from being practical, and of course, it can always fail and/or be abused, some weeks ago I saw porn ads on Youtube because they found a way to bypass their detection system using some unconventional images which us humans perceive as sexual content but they are far from what was used in the training of their systems.

Interesting. Do you know how to check if certain program has the ability to connect to the internet or not? And how to control it/disable its access to it manually?
User avatar
xElijah
Usurpation Soldier [50]
 
Posts: 96
Joined: 3 October 2020, 15:43

Re: PB2IMG2 (Add any image to your maps!)

Postby phsc » 29 November 2020, 18:54

xElijah wrote:Interesting. Do you know how to check if certain program has the ability to connect to the internet or not? And how to control it/disable its access to it manually?

There are ways to check for that, disabling it manually depends on how you run the program, if it is a .exe it is all about Windows configuration, other programs and other systems it differs, you can find tutorials on all of that quite easily I think, you can also always just unplug your internet cable, check for the internet use (while disabling everything else).
But the best and most correct way is checking the code, there are decompilers and often things are open source, but it greatly depends on the program, how it is run and how it was made.
Why are you asking?
User avatar
phsc
Noir Lime [600]
 
Posts: 694
Joined: 27 July 2013, 13:58
Location: Brazil

Re: PB2IMG2 (Add any image to your maps!)

Postby xElijah » 29 November 2020, 19:44

phsc wrote:There are ways to check for that, disabling it manually depends on how you run the program, if it is a .exe it is all about Windows configuration, other programs and other systems it differs, you can find tutorials on all of that quite easily I think, you can also always just unplug your internet cable, check for the internet use (while disabling everything else).
But the best and most correct way is checking the code, there are decompilers and often things are open source, but it greatly depends on the program, how it is run and how it was made.
Why are you asking?

Personal reasons. Thank you for info.
User avatar
xElijah
Usurpation Soldier [50]
 
Posts: 96
Joined: 3 October 2020, 15:43

Re: PB2IMG2 (Add any image to your maps!)

Postby yi en » 7 December 2020, 13:50

One question though, will this app support GUI batch commands so I can just insert a lot of images into my xml using loop method in my batch file?
User avatar
yi en
Civil Security Boss [500]
 
Posts: 556
Joined: 20 August 2013, 09:10
Location: What do you need, then?

Re: PB2IMG2 (Add any image to your maps!)

Postby phsc » 7 December 2020, 15:59

yi en wrote:One question though, will this app support GUI batch commands so I can just insert a lot of images into my xml using loop method in my batch file?

No.
However you can easily create a script/macro whatever to open the program, insert the fields and select everything, insert, then insert the new fields and select everything you want different and etc.
User avatar
phsc
Noir Lime [600]
 
Posts: 694
Joined: 27 July 2013, 13:58
Location: Brazil


Return to Tutorials

Who is online

Users browsing this forum: No registered users



cron