convertScreenShot

This routine, Screenshots.convertScreenShot() leaves a blank line down the middle when the height is an odd number.

    // flip the components the way AWT likes them
    for (int y = 0; y < height / 2; y++){
        for (int x = 0; x < width; x++){
            int inPtr  = (y * width + x) * 4;
            int outPtr = ((height-y-1) * width + x) * 4;

My quick fix is:

    // flip the components the way AWT likes them
    int yend = height/2;
    if ((height % 2) != 0) { yend += 1; }  
    for (int y = 0; y < yend; y++){
        for (int x = 0; x < width; x++){
            int inPtr  = (y * width + x) * 4;
            int outPtr = ((height-y-1) * width + x) * 4;

I can’t find any list of “known bugs” or the like for JMonkeyEngine, so I put it here.

3 Likes

I can confirm this bug in jMonkeyEngine 3.0.2

Thank you, @kcmoore!

1 Like

Curious, what are you using this class for? I sort of thought it was a candidate for removal these days so I’m curious what the use-case is.

It’s used by ScreenshotAppState when the player presses KEY_SYSRQ.

@sgold said: It's used by ScreenshotAppState when the player presses KEY_SYSRQ.

Yes, but what use does a user have for it I wonder. ScreenShotAppState will be taking screen shots… which won’t really have odd numbered heights.

If the game isn’t running maximized, the viewport can be set to an odd height using AppSettings.setHeight().

1 Like

cheers for finding + fixing this bug.

Please try and use java forum tags so we can see your code easier :slight_smile: