Dillo v3.1.1-46-g8a360e32
Loading...
Searching...
No Matches
png.c File Reference

The png decoder for Dillo. More...

#include <config.h>
#include <stdlib.h>
#include <png.h>
#include "msg.h"
#include "image.hh"
#include "cache.h"
#include "dicache.h"
Include dependency graph for png.c:

Go to the source code of this file.

Macros

#define DATASIZE   (png->ipbufsize - png->ipbufstart)
 

Enumerations

enum  prog_state { IS_finished , IS_init , IS_nextdata }
 

Functions

static void Png_error_handling (png_structp png_ptr, png_const_charp msg)
 
static void Png_warning_handler (png_structp png_ptr, png_const_charp msg)
 
static void Png_datainfo_callback (png_structp png_ptr, png_infop info_ptr)
 
static void Png_datarow_callback (png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass)
 
static void Png_dataend_callback (png_structp png_ptr, png_infop info_ptr)
 
static void Png_free (DilloPng *png)
 Free up the resources for this image.
 
static void Png_close (DilloPng *png, CacheClient_t *Client)
 Finish the decoding process (and free the memory)
 
static void Png_write (DilloPng *png, void *Buf, uint_t BufSize)
 Receive and process new chunks of PNG image data.
 
void a_Png_callback (int Op, void *data)
 PNG callback.
 
void * a_Png_new (DilloImage *Image, DilloUrl *url, int version)
 Create the image state data that must be kept between calls.
 

Detailed Description

The png decoder for Dillo.

It is responsible for decoding PNG data and transferring it to the dicache.

"PNG: The Definitive Guide" by Greg Roelofs, O'Reilly ISBN 1-56592-542-4

Definition in file png.c.

Macro Definition Documentation

◆ DATASIZE

#define DATASIZE   (png->ipbufsize - png->ipbufstart)

Definition at line 100 of file png.c.

Enumeration Type Documentation

◆ prog_state

enum prog_state
Enumerator
IS_finished 
IS_init 
IS_nextdata 

Definition at line 32 of file png.c.

Function Documentation

◆ a_Png_callback()

void a_Png_callback ( int  Op,
void *  data 
)

PNG callback.

  • Op: Operation to perform.
    • If (Op == 0) start or continue processing an image if image data exists.
    • else terminate processing, cleanup any allocated memory, close down the decoding process.
  • Client->CbData : pointer to previously allocated DilloPng work area. This holds the current state of the image processing and is kept across calls to this routine.
  • Client->Buf : Pointer to data start.
  • Client->BufSize : the size of the data buffer.

You have to keep track of where you are in the image data and how much has been processed.

It's entirely possible that you will not see the end of the data. The user may terminate transfer via a Stop button or there may be a network failure. This means that you can't just wait for all the data to be presented before starting conversion and display.

Definition at line 426 of file png.c.

References CacheClient::Buf, CacheClient::BufSize, CA_Abort, CA_Close, CA_Send, CacheClient::CbData, Png_close(), Png_free(), and Png_write().

◆ a_Png_new()

void * a_Png_new ( DilloImage Image,
DilloUrl url,
int  version 
)

Create the image state data that must be kept between calls.

Definition at line 442 of file png.c.

References _MSG, _DilloImage::bg_color, dNew0, and IS_init.

Referenced by Dicache_image().

◆ Png_close()

static void Png_close ( DilloPng *  png,
CacheClient_t Client 
)
static

Finish the decoding process (and free the memory)

Definition at line 326 of file png.c.

References _MSG, a_Dicache_close(), and Png_free().

Referenced by a_Png_callback().

◆ Png_dataend_callback()

static void Png_dataend_callback ( png_structp  png_ptr,
png_infop  info_ptr 
)
static

Definition at line 294 of file png.c.

References _MSG, IS_finished, and MSG.

Referenced by Png_write().

◆ Png_datainfo_callback()

static void Png_datainfo_callback ( png_structp  png_ptr,
png_infop  info_ptr 
)
static

◆ Png_datarow_callback()

static void Png_datarow_callback ( png_structp  png_ptr,
png_bytep  new_row,
png_uint_32  row_num,
int  pass 
)
static

Definition at line 223 of file png.c.

References _MSG, a_Dicache_new_scan(), a_Dicache_write(), and MSG.

Referenced by Png_write().

◆ Png_error_handling()

static void Png_error_handling ( png_structp  png_ptr,
png_const_charp  msg 
)
static

Definition at line 104 of file png.c.

References IS_finished, MSG, and URL_STR.

Referenced by Png_datainfo_callback(), and Png_write().

◆ Png_free()

static void Png_free ( DilloPng *  png)
static

Free up the resources for this image.

Definition at line 309 of file png.c.

References _MSG, dFree(), and MSG_WARN.

Referenced by a_Png_callback(), and Png_close().

◆ Png_warning_handler()

static void Png_warning_handler ( png_structp  png_ptr,
png_const_charp  msg 
)
static

Definition at line 118 of file png.c.

References MSG_WARN, and URL_STR.

Referenced by Png_write().

◆ Png_write()

static void Png_write ( DilloPng *  png,
void *  Buf,
uint_t  BufSize 
)
static

Receive and process new chunks of PNG image data.

Definition at line 337 of file png.c.

References _MSG, DATASIZE, dReturn_if_fail, IS_finished, IS_init, IS_nextdata, MSG_WARN, Png_dataend_callback(), Png_datainfo_callback(), Png_datarow_callback(), Png_error_handling(), Png_warning_handler(), and URL_STR.

Referenced by a_Png_callback().