function addfixx(filename,filepath,format,width,length)

%   addfixx

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.     


width = str2num(width);
length = str2num(length);
color = 'black';


file=[filepath,filename];

if ~isempty(findstr(filename,'.JPG')) | ~isempty(findstr(filename,'.JPG'))
    [picmat]=imread(file,'JPG');
    readinformat = 'JPG';
else
    [picmat]=imread(file,'bmp');
    readinformat = 'bmp';
end
    
    
[picmat]=imread(file);


if strcmp(color,'red') | strcmp(color,'all')

	picmat(240-length:240+length,320-width:320+width,1)=255  ;
	picmat(240-length:240+length,320-width:320+width,2)=0;
	picmat(240-length:240+length,320-width:320+width,3)=0;
	
	picmat(240-width:240+width,320-length:320+length,1)=255;
	picmat(240-width:240+width,320-length:320+length,2)=0;
	picmat(240-width:240+width,320-length:320+length,3)=0;
    
    if strcmp(format,'JPG')
        if strcmp(readinformat,'JPG')
            targetfilename=strrep(filename,'.JPG','.rx.JPG');
            imwrite(picmat,targetfilename,'JPG','Quality',100);
        else
            targetfilename=strrep(filename,'.bmp','.rx.JPG');
            imwrite(picmat,targetfilename,'JPG','Quality',100);
        end
    else  
        if strcmp(readinformat,'JPG')
            targetfilename=strrep(filename,'.JPG','.rx.bmp');
            imwrite(picmat,targetfilename,'bmp');
        else
            targetfilename=strrep(filename,'.bmp','.rx.bmp');
            imwrite(picmat,targetfilename,'bmp');
        end
    end
    
end

if strcmp(color,'green') | strcmp(color,'all')
    
	picmat(240-length:240+length,320-width:320+width,1)=0;
	picmat(240-length:240+length,320-width:320+width,2)=255;
	picmat(240-length:240+length,320-width:320+width,3)=0;
	
	picmat(240-width:240+width,320-length:320+length,1)=0;
	picmat(240-width:240+width,320-length:320+length,2)=255;
	picmat(240-width:240+width,320-length:320+length,3)=0;
    
   if strcmp(format,'JPG')
        if strcmp(readinformat,'JPG')
            targetfilename=strrep(filename,'.JPG','.gx.JPG');
            imwrite(picmat,targetfilename,'JPG','Quality',100);
        else
            targetfilename=strrep(filename,'.bmp','.gx.JPG');
            imwrite(picmat,targetfilename,'JPG','Quality',100);
        end
    else  
        if strcmp(readinformat,'JPG')
            targetfilename=strrep(filename,'.JPG','.gx.bmp');
            imwrite(picmat,targetfilename,'bmp');
        else
            targetfilename=strrep(filename,'.bmp','.gx.bmp');
            imwrite(picmat,targetfilename,'bmp');
        end
    end
end
    
if strcmp(color,'blue') | strcmp(color,'all')
    
    picmat(240-length:240+length,320-width:320+width,1)=0;
	picmat(240-length:240+length,320-width:320+width,2)=0;
	picmat(240-length:240+length,320-width:320+width,3)=255;
	
	picmat(240-width:240+width,320-length:320+length,1)=0;
	picmat(240-width:240+width,320-length:320+length,2)=0;
	picmat(240-width:240+width,320-length:320+length,3)=255;
    
   if strcmp(format,'JPG')
        if strcmp(readinformat,'JPG')
            targetfilename=strrep(filename,'.JPG','.bx.JPG');
            imwrite(picmat,targetfilename,'JPG','Quality',100);
        else
            targetfilename=strrep(filename,'.bmp','.bx.JPG');
            imwrite(picmat,targetfilename,'JPG','Quality',100);
        end
    else  
        if strcmp(readinformat,'JPG')
            targetfilename=strrep(filename,'.JPG','.bx.bmp');
            imwrite(picmat,targetfilename,'bmp');
        else
            targetfilename=strrep(filename,'.bmp','.bx.bmp');
            imwrite(picmat,targetfilename,'bmp');
        end
    end
end
    
if strcmp(color,'black') | strcmp(color,'all')
    
    picmat(240-length:240+length,320-width:320+width,1)=0;
	picmat(240-length:240+length,320-width:320+width,2)=0;
	picmat(240-length:240+length,320-width:320+width,3)=0;
	
	picmat(240-width:240+width,320-length:320+length,1)=0;
	picmat(240-width:240+width,320-length:320+length,2)=0;
	picmat(240-width:240+width,320-length:320+length,3)=0;
    
  if strcmp(format,'JPG')
        if strcmp(readinformat,'JPG')
            targetfilename=strrep(filename,'.JPG','.x.JPG');
            imwrite(picmat,targetfilename,'JPG','Quality',100);
        else
            targetfilename=strrep(filename,'.bmp','.x.JPG');
            imwrite(picmat,targetfilename,'JPG','Quality',100);
        end
    else  
        if strcmp(readinformat,'JPG')
            targetfilename=strrep(filename,'.JPG','.x.bmp');
            imwrite(picmat,targetfilename,'bmp');
        else
            targetfilename=strrep(filename,'.bmp','.x.bmp');
            imwrite(picmat,targetfilename,'bmp');
        end
    end
    
end





return