Rotating BufferedImage changes its colors

前端 未结 3 1259
谎友^
谎友^ 2020-12-06 23:39

I\'m trying to code a class to seam carve images in x and y direction. The x direction is working, and to reduce the y direction I thought about simply rotating the image 90

3条回答
  •  时光取名叫无心
    2020-12-07 00:21

    It seems like there's a color conversion happening due to passing null to op.filter(imgIn2, null);.

    If you change it like that it should work:

    BufferedImage last = new BufferedImage( imgIn2.getWidth(), imgIn2.getHeight(), imgIn2.getType() );
    op.filter(imgIn2, last );
    

提交回复
热议问题