(NOTE: I can not use any library which directly resize the image, I want to know the core logic of resizing )
I have an grayscale image with dimensions 256*256 . I want to modify it and create following three images a) image with dimensions 128*128 b) image with dimensions 64*64 c) image with dimensions 32*32.
pseudo code
File fi = new File("E:\\input.raw");
byte[] fileContent = Files.readAllBytes(fi.toPath());
File fo= new File("E:\\output.raw");
FileOutputStream stream = new FileOutputStream(fo);
int i=0;
for(;i<fileContent.length;i++){
//dividing by 2 to create image with dimensions 128*128
fileContent[i]= (byte) ((fileContent[i])/2);
stream.write(fileContent[i]);
}
stream.close();
Above Code does not work.It is creating image with 256*256 dimensions. Due to some reasons I am not allowed to use any library that directly reduces the dimensions. I want to know how can I convert 256*256 image to 128*128 dimensions ?