AminetAminet
Search:
84716 packages online
About
Recent
Browse
Search
Upload
Setup
Services

util/libs/dtimage.lha

Mirror:Random
Showing:m68k-amigaosppc-amigaosppc-morphosi386-arosi386-amithlonppc-warpupppc-powerupgeneric
No screenshot available
Short:Load LUT8,RGB24,RGBA32 pics via Datatypes
Author:Andreas R. Kleinert
Uploader:info ar-kleinert de
Type:util/libs
Version:3.3 (27.1.2008)
Architecture:m68k-amigaos >= 3.1.0; ppc-morphos >= 1.4.5
Date:2008-01-27
Download:http://aminet.net/util/libs/dtimage.lha - View contents
Readme:http://aminet.net/util/libs/dtimage.readme
Downloads:1696

**************************************************************************
 <Short version history is included at bottom of readme file>
**************************************************************************

dtimage.library - Freeware.

This library is freely redistributable and usable upon the conditions that this
notice remains intact and that modified versions of this archive are not
distributed
in any way. The author makes no warranty of any kind with respect to this
product
and explicitly disclaims any implied warranties of merchantability or fitness
for
any particular purpose.

If you are going to use dtimage.library within one of your programs and include
it into your program's distribution, feel free to do so. In this case you have
to add the following statement into your program's documentation:
"This program makes use of dtimage.library  at  2007-2008 by Andreas R. Kleinert".

********************************************************************************
****

dtimage.library currently only has two functions:

1. Read Image as 32 Bit RGBA
----------------------------
ULONG DTI_ReadPic32(CONST_STRPTR filename, UBYTE **image, ULONG *width, ULONG
*height, APTR future);

A typical call would look like this:

{
 ULONG bool, width, height;
 UBYTE *buffer = NULL;

 bool = DTI_ReadPic32("RAM:dummy.png", &buffer, &width, &height, NULL);
 if(bool && buffer)
  {
   // do something with RGBA32 buffer consisting of R,G,B,A bytes (width*4 bytes
per line)

   FreeVec(buffer);
  }else { ; } // check IoErr()
}

The special thing here is, that every kind of image, including 8 bit images and
single-color
transparency (like e.g. with GIF or PNG) is converted to 32 Bit RGBA data. Let's
say you have
a 256 color GIF file with color #0 being fully transparent and a 32 Bit PNG file
with several
colors transparent - it does not matter, since everything becomes direct RGBA
information.

About the data buffer format:

UBYTE rgba = { R0, G0, B0, A0, R1, G1, B1, A1, etc. }

Here R,G,B = [0..255] where { 0,0,0 } = black and { 255,255,255 } = white
and A = [0..255] where 0x00 == fully transparent and 0xFF == fully opaque.

A sample C program is included which dumps the R,G,B bytes into a P6 PPM file
and the A bytes into a grayscale P5 PGM file.

This way you can easily check if your datatypes are working properly.
Use "32" as commandline option.


2. Read Image as 8..24 Bit with optional alpha channel or transparent color
index
--------------------------------------------------------------------------------
-
ULONG DTI_ReadPic(CONST_STRPTR filename, UBYTE **image, ULONG *width, ULONG
*height,
                  ULONG *depth, LONG *transcolor, UBYTE **transmap, APTR
future);

A typical call would look like this:

{
 ULONG bool, width, height, depth;
  LONG transcolor;
 UBYTE *buffer = NULL, *map = NULL;

 bool = DTI_ReadPic("RAM:dummy.png", &buffer, &width, &height, &depth,
                    &transcolor, &map, NULL);
 if(bool && buffer)
  {
   if(depth <= 8) // can only be 1..8 or 24
    {
     UBYTE *colormap = map;

     // do something with LUT8 buffer consisting of indices (width bytes per
line)

     if(transcolor != -1) ; // then transcolor is index of transparent color

     if(colormap) ;         // then this is our colormap[256][3] RGB LUT index
table
    }else
    {
     UBYTE *transmap = map;

     // do something with RGB24 buffer consisting of R,G,B bytes (width*3 bytes
per line)

     if(transcolor == -2) ; // then transmap is pointer to alpha channel buffer
      {
       if(transmap) ;       // then this is our alpha[width*height] transparency
information
      }
    }

   if(transmap) FreeVec(transmap);
   FreeVec(buffer);
  }else { ; } // check IoErr()
}

The issue here is, that either 24 Bit RGB data with or without alpha channel
or 8 Bit LUT data with colormap and optional transparent color may be returned,

About the data buffer format for 8 bit:

UBYTE lut = { I0, I1, I2, etc. }

Here "In" is an index into a colormap[256][3] array with 256 RGB entries
where R,G,B = [0..255] with { 0,0,0 } = black and { 255,255,255 } = white.

About the data buffer format for 24 bit:

UBYTE rgb = { R0, G0, B0, R1, G1, B1, etc. }

Here R,G,B = [0..255] where { 0,0,0 } = black and { 255,255,255 } = white.

For transcolor == -2 a transcolor map for each color is returned,
which contains as many entries as pixels with alpha (A) values with
A = [0..255] where 0x00 == fully transparent and 0xFF == fully opaque.

A sample C program is included which for 24/32 bit dumps the R,G,B bytes
into a P6 PPM file and the A bytes into a grayscale P5 PGM file. For 8 bit
it does a 8->24 bit conversion and dumps the result as P6, in addition
to the LUT itself which is dumped as P5.

This way you can easily check if your datatypes are working properly.
Use "8" as commandline option.

********************************************************************************
****

Warning: There is at least one V45 version of picture.datatype in some OS
version
         which does NOT support alpha channel export (always returns fixed value
         for alpha byte, no matter what is set by the corresponding image
Datatype).

********************************************************************************
****

Main changes since previous versions:

V3.3 (27.1.2007):

 - now sets PDTA_Remap and new() time
   to avoid problems with some AfaOS versions
   (-> Bernd Roesch)
 - fixed 3.2 version string
 - fixed V3.2 history

V3.2 (26.1.2007):

 - now always sets PDTA_DitherQuality to 0
   (-> Thomas Klein)

V3.1 (5.1.2007):

 - bumped main version for easier distinction
 - added comments in includes regarding V1/V2/V3 differences
 - fixed minor bug in 8->32 bit conversion

V2.3 (4.1.2007):

 - added MOS .elf version
 - added MOS ppcline .h files
   (-> Stefan Haubenthal)
 - fixed bug (file resources/handle not released)
   (-> Stefan Haubenthal)

********************************************************************************
****

© 2007-2008 by Dipl.-Ing. Andreas Kleinert. All rights reserved.


Contents of util/libs/dtimage.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO METHOD CRC     STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[generic]                 2346    6260  37.5% -lh5- a8ce Jan 27 21:10 dtimage.readme
[generic]                 3166    5324  59.5% -lh5- c375 Jan 27 21:10 libs/dtimage.library
[generic]                 6759   14100  47.9% -lh5- 35db Jan 27 21:10 libs/dtimage.library.elf
[generic]                  177     275  64.4% -lh5- 5248 Jan 27 21:10 programmers/fd/dtimage.fd
[generic]                  110     149  73.8% -lh5- 6588 Jan 27 21:10 programmers/fd/make_ppcinline.bat
[generic]                  343     900  38.1% -lh5- 2463 Jan 27 21:10 programmers/include/clib/dtimage_protos.h
[generic]                  418    1423  29.4% -lh5- ac00 Jan 27 21:10 programmers/include/dtimage/dtimage.h
[generic]                  357     843  42.3% -lh5- c3dd Jan 27 21:10 programmers/include/dtimage/dtimagebase.h
[generic]                  360    1027  35.1% -lh5- 26ae Jan 27 21:10 programmers/include/ppcinline/dtimage.h
[generic]                  238     425  56.0% -lh5- 80a5 Jan 27 21:10 programmers/include/pragmas/dtimage_pragmas.h
[generic]                  209     335  62.4% -lh5- 42d6 Jan 27 21:10 programmers/include/proto/dtimage.h
[generic]                  123     164  75.0% -lh5- 8ce6 Jan 27 21:10 programmers/sample/scoptions
[generic]                   72     120  60.0% -lh5- ba28 Jan 27 21:10 programmers/sample/smakefile
[generic]                   70      77  90.9% -lh5- 53cb Jan 27 21:10 programmers/sample/smakefile.wth
[generic]                 5851    9404  62.2% -lh5- 812c Jan 27 21:10 programmers/sample/TestDTI
[generic]                 1458    5761  25.3% -lh5- 2d80 Jan 27 21:10 programmers/sample/TestDTI.c
[generic]                  297     604  49.2% -lh5- 6987 Jan 27 21:10 programmers/sample/TestDTI.h
[generic]                  383     831  46.1% -lh5- c091 Jan 27 21:10 programmers/sample/TestDTI.info
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total        18 files   22737   48022  47.3%            Jan 27 16:50

Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>