Created
November 19, 2019 16:22
-
-
Save MrSnyder/6cee3d5d4fdf8c60fc90e13deef1252f to your computer and use it in GitHub Desktop.
Bootstrap gridifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
public class BootstrapGridifier { | |
public static void main(String[] args) throws IOException { | |
BufferedImage img = ImageIO.read(new File("/tmp/sauron.png")); | |
for (int y = 0; y < img.getHeight(); y++) { | |
System.out.println("<div class='row no-gutters'>"); | |
for (int x = 0; x < img.getWidth(); x++) { | |
int intColor = img.getRGB(x, y); | |
// int: 4 bytes: ARGB / aarrggbb | |
int red = intColor >> 16 & 0xff; | |
int green = intColor >> 8 & 0xff; | |
int blue = intColor & 0xff; | |
String color = "rgb(" + red + "," + green + "," + blue + ")"; | |
System.out.println(" <div style='background-color: " + color | |
+ "' class='col-1 embed-responsive embed-responsive-1by1'></div>"); | |
} | |
System.out.println("</div>"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
</head> | |
<body> | |
<div class="container-fluid"> | |
<!-- paste generated rows here --> | |
</div> | |
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment