Skip to content

what is the optimal workflow to encode bufferedimage animations of TYPE_INT_ARGB (alpha composite)? #2085

Answered by istinnstudio
istinnstudio asked this question in Q&A
Discussion options

You must be logged in to vote

OK I have found a solution and surprisingly is fast enough in my case. Here is the code for conversion on the BufferedImage level and used in convertImageToFrame,.

   public BufferedImage convertChannelsOnBufferedImageARGBtoRGBA(BufferedImage sourceImage) {
    int width = sourceImage.getWidth();
    int height = sourceImage.getHeight();
    
    BufferedImage targetImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    
    int[] sourceData = ((DataBufferInt) sourceImage.getRaster().getDataBuffer()).getData();
    int[] targetData = ((DataBufferInt) targetImage.getRaster().getDataBuffer()).getData();
    
    for (int i = 0; i < sourceData.length; i++) {
        // As…

Replies: 1 comment 15 replies

Comment options

You must be logged in to vote
15 replies
@saudet
Comment options

@istinnstudio
Comment options

@saudet
Comment options

@istinnstudio
Comment options

Answer selected by istinnstudio
@saudet
Comment options

@istinnstudio
Comment options

@saudet
Comment options

@istinnstudio
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants