Menu

saving PGF file

Discussion
Aris Basic
2011-01-11
2013-05-02
  • Aris Basic

    Aris Basic - 2011-01-11

    is this working in current trunk version ?
    Write() seems to work on m_wtChannel data but nothing calls into encoder (i think all i have output are headers)
    but no level data or anything like that (shouldnt Write output everything to stream ?? )

     
  • Raphael Schweizer

    Yes, current trunk is supposed to be working. CPGFImage::Write (PGFimage.cpp, line 882) takes a CPGFStream to write to.
    For encoding the workflow usually would look like this (see Console (pgf folder in svn)):
    - Read source image (the console uses FreeImage)
    - Create and set PGF header (and set desired values)
    - Import the image into the PGFImage (will do downsampling / YUV transformation if needed)
    - Write to the stream (will do wavelet transformation / encoding)

    Feel free to ask any follow-up questions.

    - Raphael

     
  • Aris Basic

    Aris Basic - 2011-01-12

    this is how i tried to do it (with 16bit gray and RGB data)
    all i get in file is header data nothing else

    PGFHeader pgfHeader;
    memset(&pgfHeader,0,sizeof(PGFHeader));
    pgfHeader.channels = image.NChannels();
    pgfHeader.height = image.Height();
    pgfHeader.width = image.Width();
    pgfHeader.nLevels = 5;
    pgfHeader.quality = lossless?0:MaxQuality;
    pgfHeader.mode = getPGFMode(image);
    pgfHeader.bpp = 0;
    CPGFImage pgfImage;
    pgfImage.SetHeader(pgfHeader,PGFVersion);
    pgfImage.ImportBitmap(image.Step(),image.DataPtr(),image.Precision());

    HANDLE fileHandle = CreateFile(filename.c_str(),GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
    if (fileHandle == INVALID_HANDLE_VALUE)
    OPAL_THROW(format("Unable to CreateFile ") % filename.c_str());

    CPGFFileStream fileStream(fileHandle);

    pgfImage.Write(&fileStream)

     
  • Raphael Schweizer

    Most likely the problem is "pgfHeader.bpp = 0", try setting BitsPerPixel to a value > 0 and <= 31 (e.g. 16, values  > 31 will be ignored)

     

Log in to post a comment.

MongoDB Logo MongoDB