unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Menus;

type
  TForm1 = class(TForm)
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    MainMenu1: TMainMenu;
    File1: TMenuItem;
    eXit1: TMenuItem;
    Convert1: TMenuItem;
    Help1: TMenuItem;
    About1: TMenuItem;
    procedure Button1Click(Sender: TObject);
    procedure eXit1Click(Sender: TObject);
    procedure About1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
jpegbuff        :array[0..100000] of byte;
headerbuff        :array[0..19] of byte;

x,z,
bytesread       :Integer;
infile, outfile :File;
begin
   headerbuff[0]:=$ff;
   headerbuff[1]:=$d8;
   headerbuff[2]:=$ff;
   headerbuff[3]:=$e0;
   headerbuff[4]:=$00;
   headerbuff[5]:=$10;
   headerbuff[6]:=$4a;
   headerbuff[7]:=$46;
   headerbuff[8]:=$49;
   headerbuff[9]:=$46;
   headerbuff[10]:=$00;
   headerbuff[11]:=$01;
   headerbuff[12]:=$01;
   headerbuff[13]:=$00;
   headerbuff[14]:=$00;
   headerbuff[15]:=$01;
   headerbuff[16]:=$00;
   headerbuff[17]:=$01;
   headerbuff[18]:=$00;
   headerbuff[19]:=$00;

   opendialog1.Options := [ofAllowMultiSelect];
   if(opendialog1.execute=False) then exit;
   for x:=0 to (opendialog1.Files.Count-1) do
      begin
         assignfile(infile,opendialog1.files.strings[x]);
         reset(infile,1);
         blockread(infile,jpegbuff[0],100000,bytesread);
         closefile(infile);
//         showmessage(inttostr(bytesread));
         if(bytesread>160) then
            begin
               assignfile(outfile,opendialog1.files.strings[x]+'.jpg');
               rewrite(outfile,1);
               blockwrite(outfile,headerbuff[0],20,z);
               blockwrite(outfile,jpegbuff[160],bytesread-160,z);
               closefile(outfile);
            end;
      end;
   showmessage(inttostr(opendialog1.Files.Count)+' Files converted');

end;



procedure TForm1.eXit1Click(Sender: TObject);
begin
Form1.close;
end;

procedure TForm1.About1Click(Sender: TObject);
var
locs :String;
begin
locs:='Samsung A680 image converter 1.0'+chr($0d)+chr($0a);
locs:=locs+'Les Hildenbrandt'+chr($0d)+chr($0a);
locs:=locs+'les@hildenbrandt.com'+chr($0d)+chr($0a);
locs:=locs+'3/14/2006';

Showmessage(locs);
end;

end.
