Last active
July 27, 2020 21:07
-
-
Save Bloodb0ne/e152a591bc1ecda277df5c257f82ea34 to your computer and use it in GitHub Desktop.
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
bool isValidOffset(int x,int y,int width,int height){ | |
if(x < 0 || x > width) return false; | |
if(y < 0 || y > width) return false; | |
return true; | |
} |
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
for(int i=0;i<info.height;i++) | |
for(int j=0;j<=info.width;j++) | |
{ | |
if(j==info.width) //pad | |
{ | |
int padding = 4 - ((info.width * 3) % 4); | |
if(padding == 4) | |
padding = 0; | |
for(int k=0;k<padding;k++) | |
file.read((char*)&temp_pad,sizeof(u_int8)); | |
}else | |
file.read((char*)&datamap[i][j],sizeof(RGB)); | |
} |
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
for (int i = 0; i < height; i++) { | |
int nullbytes = 4 -(width % 4); | |
if(nullbytes == 4) { | |
nullbytes = 0; | |
} | |
int splitWidth = Math.round((double)width / 8); | |
for (int j = 0; j < splitWidth; j++) { | |
if(j == splitWidth){ | |
byteStream.skipBytes(nullbytes); | |
}else{ | |
byte b = byteStream.readByte(); | |
for(int k = 0; k <= 8;k++){ | |
if((j+k)*8 <= width){ | |
System.out.println("I:= %d J:= %d",i,j*k); | |
PixelArray[i][j+k] = (b & (byte)Math.pow(k,2)) == 1; | |
} | |
} | |
} | |
} | |
} | |
BufferedImage image = new BufferedImage(WIDTH,HEIGHT,BufferedImage.TYPE_INT_RGB); | |
for(int i=0;i<WIDTH;i++){ | |
for(int j=0;j<HEIGHT;j++){ | |
if(PixelArray[i][j]) image.setRGB(i, j, Color.BLACK.getRGB()); | |
if(!PixelArray[i][j]) image.setRGB(i, j, Color.WHITE.getRGB()); | |
} | |
} | |
ImageIO.write(image, "png", new File("C:\\out.png")); |
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
from 0 to height: | |
from 0 to width: | |
if we are at the end of the row: | |
calculate padding and skip it | |
else: | |
read the value | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment