Code Monkey home page Code Monkey logo

libattopng's People

Contributors

7890 avatar misc0110 avatar thebigbadme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

libattopng's Issues

[Feature Request] Support 16 bit depth

Hi, thanks for this library! Currently, information can only be encoded up to a bit depth per pixel of 8. Would it be possible to also support 16-bit pixel values?

malloc() -> calloc()

valgrind tells that saving a png file can in some cases lead to "Use of uninitialised value".

Proposing to use calloc() instead of malloc() in libattopng_new():

png->data = (char *) malloc(png->capacity);

Test program

#include <libattopng.h>
int main(int argc, char *argv[]) {
        libattopng_t *png = libattopng_new(10, 10, PNG_RGBA);
        libattopng_save(png, "/tmp/test.png");
        libattopng_destroy(png);
        return 0;
}
// valgrind -v ...

Width limit for PNG

Hey! I'm using this library to generate huge images (128000 x 96000 for example), and I'm encountering the problem of max 65k pixels.
After some search, it seems to be due to chunk limit which is of this size, but I also found that PNG do not have width or height limit...
Do you think there is any way this could be implemented, or maybe you have done more research than I have and you've got a reason why there's a limit?

Thanks in advance :)

Project has MIT license but source has LPGLv3

In 7d8441a the license of the project (LICENSE) was changed from LGPLv3 to MIT, however both libattopng.c and libattopng.h still start with a LGPLv3 header.

Is the library available under MIT as the main license file and the commit seem to suggest? Or is it available only under LPGLv3 as the source code would suggest?

Problem with color

I am using ffmpeg libs to extract frames from video.
I want to save frames to png and i found libattopng for this purpose.
Аfter getting the RGB information about the frame, I use the following procedure:

void save_frame_as_png(AVFrame *pFrame, int width, int height, size_t frameNum)
#define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16) | (0xff << 24))
#define R(x, y) 3*(x + y*width) + 0
#define G(x, y) 3*(x + y*width) + 1
#define B(x, y) 3*(x + y*width) + 2
{
    char szFilename[32];
    int  y;

    sprintf(szFilename, "frames/frame%d.png", (int)frameNum);

    libattopng_t* png = libattopng_new(width, height, PNG_RGB);
    char *pColorChannel = pFrame->data[0];
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            libattopng_set_pixel(png, x, y,
                RGB(pColorChannel[R(x, y)],
                    pColorChannel[G(x, y)],
                    pColorChannel[B(x, y)])
            );
        }
    }

    libattopng_save(png, szFilename);
    libattopng_destroy(png);
}

But after saving the file, there are blue spots on the image (what is more, where colors are close to white).

I have the procedure that saving frame to .ppm (from http://dranger.com/ffmpeg/tutorial01.html):

void save_frame_as_ppm(AVFrame *pFrame, int width, int height, size_t frameNum) {
    FILE *pFile;
    char szFilename[32];
    int  y;

    sprintf(szFilename, "frames/frame%d.ppm", (int)frameNum);
    pFile = fopen(szFilename, "wb");
    if (pFile == NULL)
        return;

    // Write header of ppm file
    fprintf(pFile, "P6\n%d %d\n255\n", width, height);
    // Write pixel data
    for (y = 0; y < height; y++)
        fwrite(pFrame->data[0] + y * pFrame->linesize[0], 1, width * 3, pFile);

    fclose(pFile);
}

Example of frame, that saved as .png and .ppm: frame10.zip
All code: https://pastebin.com/eL7AizFU

So, my question is: do I use the library libattopng correctly? Is there a solution to the blue areas in my context?

Core dump on very large images

I have the following chunk of code:

  libattopng_t* png = libattopng_new( xsize, ysize, PNG_RGBA );
  for( int y = 0; y < ysize; y++ )
  {
    for( int x = 0; x < xsize; x++ )
    {
      libattopng_set_pixel(png, x, ysize - y, image[x][y]);
    }
    //printf( "%d\n", y );
  }
  libattopng_save( png, output_file_name );
  libattopng_destroy( png );

When I set xsize = 4,320 and ysize = 2,160 then everything works fine.
However when I set xsize = 21,600 and ysize = 10,800 ( 233,280,000 pixels ) then I get a core dump. The png file has about 900 Mbytes written to it before the crash but is corrupted somehow.

From a quick investigation the crash seems to be caused by the free(png->data); line in libattopng_destroy. However if I comment out the call to libattopng_destroy the program terminates normally without a crash but the resulting PNG file is still corrupt.

Before I investigate any further would you expect the library to handle these large file sizes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.