comp.lang.ada
 help / color / mirror / Atom feed
From: gautier_niouzes@hotmail.com
Subject: Re: Question: re Image Files.
Date: Fri, 31 Aug 2012 14:12:59 -0700 (PDT)
Date: 2012-08-31T14:12:59-07:00	[thread overview]
Message-ID: <61c38064-4eef-425d-8936-c68f68ca6dbd@googlegroups.com> (raw)
In-Reply-To: <50406532$0$10734$5b6aafb4@news.zen.co.uk>


Le vendredi 31 août 2012 09:18:11 UTC+2, Mark Murray a écrit :

> Yes, but you have to handle each individual image format (GIF, JPEG,
> BMP etc) separately. This is a LOT of work to write a general program.

Sure. The good news is that it is already done :-)
Download or check-out GID: http://gen-img-dec.sf.net/ 
Then all the work is to define a container, say a flat byte buffer or a two-dimensional array, then define 2 procedures, e.g. here for a flat buffer:

    procedure Set_X_Y (x, y: Natural) is
    begin
      idx:= 3 * (x + image_width * (image_height - 1 - y));
    end Set_X_Y;
    --
    procedure Put_Pixel (
      red, green, blue : Primary_color_range;
      alpha            : Primary_color_range
    )
    is
    begin
      buffer(idx..idx+2):= (red, green, blue);
      idx:= idx + 3;
    end Put_Pixel;

plus a feedback procedure that can be null (just there for showing progess), then instanciate a procedure:

    procedure Load_image is
      new GID.Load_image_contents(
        Primary_color_range, 
        Set_X_Y,
        Put_Pixel, 
        Feedback, 
        GID.fast
      );

An that's it! PNG, BMP, GIF, JPEG, TGA are auto-detected.
You don't need to tell GID under what format the image is encoded.
I guess Austin is trying to do steganography.
The simplest way it to take test\mini.adb and customize it for that purpose.
Have fun!
_________________________ 
Gautier's Ada programming 
http://freecode.com/users/gdemont



  parent reply	other threads:[~2012-08-31 21:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-30 22:33 Question: re Image Files Austin Obyrne
2012-08-30 22:55 ` Adam Beneschan
2012-08-31  1:35 ` tmoran
2012-08-31  7:16 ` Dmitry A. Kazakov
2012-08-31  7:18 ` Mark Murray
2012-08-31  8:58   ` Austin Obyrne
2012-08-31  9:25     ` Ludovic Brenta
2012-08-31  9:41       ` Dmitry A. Kazakov
2012-08-31  9:14   ` Austin Obyrne
2012-08-31 17:09     ` Mark Murray
2012-08-31 17:36       ` Austin Obyrne
2012-08-31 22:09         ` Shark8
2012-09-04 10:05         ` Antti Louko
2012-08-31 21:12   ` gautier_niouzes [this message]
2012-09-01  6:58     ` Austin Obyrne
2012-09-03  6:02   ` Anatoly Chernyshev
2012-09-03  7:27     ` Mark Murray
2012-08-31  8:41 ` Brian Drummond
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox