Java BufferedImage Operation repairImage(final BufferedImage bfi, final List order)

Here you can find the source of repairImage(final BufferedImage bfi, final List order)

Description

repair Image

License

Apache License

Declaration

public static BufferedImage repairImage(final BufferedImage bfi, final List<Integer> order) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static BufferedImage repairImage(final BufferedImage bfi, final List<Integer> order) throws IOException {

        final List<BufferedImage> list = new ArrayList<>();
        final int width = bfi.getWidth();

        for (int i = 0, k = width / 12; i < k; i++) {
            list.add(bfi.getSubimage(12 * i + 1, 0, 11, 58));
        }//w ww.  j a v a  2  s  .  com

        for (int i = 0, k = width / 12; i < k; i++) {
            list.add(bfi.getSubimage(12 * i + 1, 58, 11, 58));
        }

        final List<BufferedImage> orderList = new ArrayList<>();
        for (final int i : order) {
            orderList.add(list.get(i));
        }

        final BufferedImage oriBfi = getOriPicture(orderList);

        // ImageIO.write(oriBfi, "png", new File("d://x.webp"));
        return oriBfi;
    }

    private static BufferedImage getOriPicture(final List<BufferedImage> orderList) {
        final BufferedImage bfi = new BufferedImage(260, 116, BufferedImage.TYPE_4BYTE_ABGR);

        final Graphics g = bfi.getGraphics();
        for (int i = 0; i < 26; i++) {
            g.drawImage(orderList.get(i), i * 10, 0, null);
        }

        for (int i = 26; i < 52; i++) {
            g.drawImage(orderList.get(i), (i - 26) * 10, 58, null);
        }

        return bfi;
    }
}

Related

  1. prepareModel(BufferedImage model)
  2. recolor(BufferedImage img, int newColor)
  3. recolor(BufferedImage src, Color sc)
  4. recombine(BufferedImage[][] blocks)
  5. reorientImage(BufferedImage image, boolean yAxisFlipNeeded, int cwRotationNeeded)
  6. resampleImage(BufferedImage image, int height)
  7. resampleWithAffineTransformOp(BufferedImage srcImage, double sx, double sy)
  8. revertBlackAndWhite(BufferedImage img)
  9. roate90(BufferedImage src)