Hello Guest

Take screen shoot problem it include big black space from the right and bottom.

  • 0 Replies
I am developing a video editing software.  I use opencv to read and write video and lwjgl shader for the effects...
My problem is the screenshot doest not work properly..

If the video size is 1280x720 this code doest not work properly on saving image ( ImageIO.write  ... )
and recording video using opencv it include big black space from the right and bottom corner.

if the video size is 800x480 it works properly no black space from the right and bottom.

While playing the video there is no problem no black space from the right and bottom of the display windows for both video size 1280x720 and  800x480,
but the problem is on recorded video and save image using the code bellow..

Code: [Select]
private BufferedImage glToBufferdImage(int width, int height) {
        //First off, we need to access the pixel data of the Display. Without this, we don't know what to save!
        //int width = WINDOW_WIDTH;
        //int height= WINDOW_HEIGHT;
        int bpp = 4; // Assuming a 32-bit display with a byte each for red, green, blue, and alpha.
        ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp);
        GL11.glReadPixels(0, 0, width, height, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer );
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        for(int x = 0; x < width; x++)
            for(int y = 0; y < height; y++)
                int i = (x + (width * y)) * bpp;
                int r = buffer.get(i) & 0xFF;
                int g = buffer.get(i + 1) & 0xFF;
                int b = buffer.get(i + 2) & 0xFF;
                image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b);
        return image;

Any help?
« Last Edit: April 10, 2018, 02:20:54 by jhovarie »