logo
down
shadow

Java - Splitting a image into 4 images


Java - Splitting a image into 4 images

By : Ahmad
Date : December 01 2020, 05:00 PM
like below fixes the issue You should start by scaling down your original image to 1/4 size (see this StackOverflow answer for details - use at.scale(0.5, 0.5) instead of 2.0,2.0).
Then you loop over the x and y dimensions of the scaled-down image and in your "corner" images and 4 times you set the pixel with x and y offsets:
code :
for (int x = 0; x < scaledImageWidth; x++) {
    for (int y = 0; y < scaledImageHeight; y++) {
            imageTL.setRGB (x, y, scaledImagePixels[x][y]);
            imageTR.setRGB (x + scaledImageWidth, y, scaledImagePixels[x][y]);
            imageBL.setRGB (x, y + scaledImageHeight, scaledImagePixels[x][y]);
            imageBR.setRGB (x + scaledImageWidth, y + scaledImageHeight, scaledImagePixels[x][y]);
    }
}  


Share : facebook icon twitter icon
Will splitting one big image into 4 smaller images reduce load time?

Will splitting one big image into 4 smaller images reduce load time?


By : user3061792
Date : March 29 2020, 07:55 AM
it helps some times Slicing big image into smaler images can reduce loading time because modern browsers can load these images in the same time (in pararell). But each image takes time in loading flow:
Browser makes reques Waits for response, Then loads.
Splitting a multipage TIFF image into individual images (Java)

Splitting a multipage TIFF image into individual images (Java)


By : Ricky Dewayne Caldwe
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You can use the Java Advanced Imaging library, JAI, to split a mutlipage TIFF, by using an ImageReader:
code :
ImageInputStream is = ImageIO.createImageInputStream(new File(pathToImage));
if (is == null || is.length() == 0){
  // handle error
}
Iterator<ImageReader> iterator = ImageIO.getImageReaders(is);
if (iterator == null || !iterator.hasNext()) {
  throw new IOException("Image file format not supported by ImageIO: " + pathToImage);
}
// We are just looking for the first reader compatible:
ImageReader reader = (ImageReader) iterator.next();
iterator = null;
reader.setInput(is);
nbPages = reader.getNumImages(true);
reader.read(numPage)
Splitting an Image Object into a 2D Array in Java

Splitting an Image Object into a 2D Array in Java


By : user3103209
Date : March 29 2020, 07:55 AM
To fix this issue Take a look at Java converting Image to BufferedImage
It provides a way to convert from Image to BufferedImage, which seems to be the problem.
(Image in loop) Huge array of images and wants to display if image is really present then show the images otherwise dele

(Image in loop) Huge array of images and wants to display if image is really present then show the images otherwise dele


By : Paul-CNB
Date : March 29 2020, 07:55 AM
I hope this helps you . If you want to check image URL exist or not, You can try this with javaScript, It will check all URLs one by one and call the callBack function, then it will call URL check for next URL. Next URL will be check after one completes, no matter how much time it will take.
code :
function isImageExists(imgSrc, callBackAfterCheck) {
   var img = new Image();
   img.onload = function() { callBackAfterCheck(true) };
   img.onerror = function() {callBackAfterCheck(false) };
   img.src = imgSrc;
}

var urlArray = [{productImage:'http://www.queness.com/resources/images/png/appleeeeeee_ex.png'},{productImage:'https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'},{productImage:'https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_cooooooolor_272x92dp.png'},{productImage:'https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'}];


var imageIndex = 0;
function callBackAfterCheck(status){
   if(status == true){
     //do your stuff here
     console.log('image Exist');
   }else{
     //do your stuff here
    console.log('image not Exist');
   }
   imageIndex++
   if(imageIndex < urlArray.length){
     var imageUrl = urlArray[imageIndex].productImage;
     isImageExists(imageUrl, callBackAfterCheck)
   }
}

var imageUrl = urlArray[imageIndex].productImage;
isImageExists(imageUrl, callBackAfterCheck);
Java: Splitting .GIF image in BufferedImages Gives Malformed Images

Java: Splitting .GIF image in BufferedImages Gives Malformed Images


By : Diego PzRz
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You solved it yourself, but for good order: every next frame is the accumulation of all prior frames filling up the transparent pixels in the current frame.
code :
public static void splitGif(File file) throws IOException {
    ImageReader reader = ImageIO.getImageReadersBySuffix("gif").next();
    reader.setInput(ImageIO.createImageInputStream(new FileInputStream(file)), false);
    BufferedImage outImage = null;
    Graphics2D g = null;    
    for (int i = 0; i < reader.getNumImages(true); i++) {
         BufferedImage image = reader.read(i);
         if (g == null) {
             BufferedImage outImage = new BufferedImage(image.getWidth(), image.getHeight(),
                     BufferedImage.TYPE_4BYTE_ABGR);
             g = (Graphics2D) outImage.getGraphics();
         }
         g.drawImage(lastImage, 0, 0, null);
         ImageIO.write(outImage, "PNG", new File(i + ".png"));
     }
     if (g != null) {
         g.dispose();
     }
}
Related Posts Related Posts :
  • My shape moved but will pause for a while
  • How to solve syntax error in eclipse Mars.1
  • Shibboleth idp configuration for ldap authentication
  • Do something when app starts?
  • Android Runtime Exception font asset not found
  • How to query using objectify in Google App Engine app
  • List value is printing address instead of value
  • StringUtils.isBlank return false for null Strings
  • Sent parameter through PATCH android
  • i am not able to clear the code below given using throwable concept in java
  • How to get System time instead of Server time in java?
  • How to push json data into an arrya object in MONGO DB by java
  • Saving RelationshipEntity not working
  • Error on "instanceOf" when checking a subClass
  • "Pinging" a server in Java
  • RoboGuice Proguard CreationException
  • Android Array list returns Null after adding values
  • Jar Executable what am I doing wrong?
  • How do I mitigate Connection leak triggered for connection com.mysql.jdbc.JDBC4Connection@11d08960,
  • How do i iterate values from a 2d array using conditions
  • Hide Button in CustomPagerAdapter
  • Java GC: does it ever make sense to call super.finalize() in a class that only extends Object?
  • 64bit HashMap in Java
  • Hibernate wildcard query on two columns
  • Want to Generate Auto Login Program Using Java
  • Spring security Oauth 2 with ajax login and form login
  • Parse findInBackground doesn't add to global arraylist?
  • Remove random item from ArrayList
  • in SpringMVC getMessage from i18n properties in a function outside the controller
  • How do I add JCheckBox next to each name that has been entered into an arraylist from a JTextField?
  • Return node ID along with complete node
  • InvocationTargetException. Cannot cast class X to class X. When invoked in Scala Imain through spark-submit
  • how to print elements of a 1D array into a N x N box
  • How to map csv file to pojo class in java
  • How, in Java, to encode default vhost %2F in URL/URI so it doesn't get changed to slash and fail to work
  • Tomcat 5.5 https configuration in Windows Server 2008 64bit
  • Enabling FIPS 140-2 compliance mode in MULE ESB
  • How to pass String PackageName to PkgName under parseXML() and run XMLParser class as a new activity when click on list
  • Error while creating spring -hibernate configuration file
  • Hand off control between java threads
  • NoClassDefFoundError: scala/collection/Seq
  • Getting stack overflow error on one machine but not the other on the same code
  • How can I loop AsyncAjaxRequest in GWT?
  • Failed to find provider info for urbanairship.provider
  • Android ListView Adapter Crash issue/Duplicates
  • Displaying Splash screen only once on user preference
  • Loop List<WebElement> doesn't stop despite no more WebElements
  • Check if pattern exists in a String
  • Swing - Key Problems (Arrow Keys, Tab, etc.) in GUIs with TextComponents
  • Why the solution for binary search tree validity is not working?
  • Double encrypting 2048 RSA?
  • create junit test for runnable class
  • Unable to read and sort information from a text file in Java
  • My device isn't getting detected in android studio (driver issue)
  • Representing a Graph in Java
  • How to XML mapping using jxls
  • Quick Sort stackoverflow error for large arrays
  • Parsing Apache Tika XML Output returns Unknown Tag
  • java simple UI loop, can't find bug
  • how to use greater than and less than in a single if statement in java
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co