SIMPLE_JPEG_LIB MANUAL


Next: , Previous: (dir), Up: (dir)


Next: , Previous: Top, Up: Top

1 Introduction to the simple_jpeg_lib

Simple_Jpeg_Lib is a simple library that permit to load, save and use jpeg files. This library provide a simple set of functions for jpeg manipulation.


Next: , Previous: Introduction, Up: Top

2 Compiling Ada programs with the Simple_Jpeg_Lib

Simple_Jpeg_Lib contains a small c wrapper to easy the binding with the jpeglib. this wapper c_simple_jpeg_lib.c must be compiled with the same compiler of the jpeglib, or the same compile options (internal jpeglib structures must have the same definition in the jpeglib and in the wrapper).

2.0.1 compiling the simple_jpeg_lib


rem
rem Simple script for compiling Ada Jpeg Bindings
rem 

gcc -c -g c_simple_jpeg_lib.c -I../Dependencies/jpeg-6b

gnatmake -c -g -gnatf simple_jpeg_lib.adb

2.0.2 compiling a program with the simple_jpeg_lib

To compile your program, you must first compile the simple_jpeg_lib, and then link to your program :

Example :

     
     gcc -c  ../src/c_simple_jpeg_lib.c -I../Dependencies/jpeg-6b
     
     gnatmake -g -gnatf -gnatov -gnaty -I../src test_jpeg_reader -largs c_simple_jpeg_lib.o -ljpeg -bargs -E
     
     


Previous: Compiling, Up: Top

3 Using the simple_jpeg_lib

3.1 reading a jpeg file

     
     with simple_jpeg_lib;
     use simple_jpeg_lib;
     
     procedure test_jpeg_reader is
     
        J : Jpeg_Handle_decompress;
        JC : Jpeg_Handle_Compress;
        I:Integer := 0;
     
     begin
     
            -- open image, and decompress it with 1/8 of the original size
           Open_Jpeg("sample.jpg",J,8);
     
           -- Get Informations
           declare
              W,H : Dimension ;
              Jpegtype : Jpeg_Type;
           begin
              Get_Image_Info(J,W,H,jpegtype);
     
              Text_Io.Put(" Width :" & dimension'Image(W)
                          & " , height " & dimension'Image(h)
                          & " , nb comp : " & Jpeg_type'Image(jpegtype) );
     
              Create_Jpeg("output.jpg",Jc,W,H,jpegtype);
           end;
     
           declare
           begin
              while True loop
                 declare
                    Comp : Component_Array := Read_Next_Line(J);
                 begin
                    Write_Line(JC,Comp);
                    I:=I+1; -- count the lines
                 end;
              end loop;
           exception
              when JPEG_EXCEPTION  =>
                 null;
           end;
     
           Text_Io.New_Line;
           Text_Io.Put( Integer'Image(I) & " read Lines ");
     
           Close_Jpeg(J);
           Close_Jpeg(jc);
     
           Text_Io.Put("End  ");
           Text_Io.New_Line;
     
     exception
             when E : others =>
                Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E));
     
     end;
     

Concept Index

Table of Contents