Code covered by the BSD License  

Highlights from
Hieroglyphs

image thumbnail
from Hieroglyphs by Ligong Han
Latin alphabet to Egyptian hieroglyphs Translator

hieroglyphs_with_cartouche(str,nl)
function cpic = hieroglyphs_with_cartouche(str,nl)
%HIEROGLYPHS_WITH_CARTOUCHE   translate Latin alphabet to ...
%   Egyptian hieroglyphs with cartouche.

if nargin > 0
    if ~iscell(str)
        str = {str};
    end
    n_c = length(str);
    if nargin == 1
        nl = Inf(1,n_c);
    elseif nargin == 2
        if length(nl) < n_c
            nl = [nl,Inf(1,n_c-length(nl))];
        end
    else
        fprintf('Too many input arguments.\n');
        cpic = {};
        return
    end
else
    %GUI
    answer = inputdlg({'Enter the string:',...
        'Number of letters in a line:'},...
        'Input for Hieroglyph Convertor',...
        3,{'HIEROGLYPH','Inf'},'on');
    if isempty(answer)
        return
    end
    str = answer(1);
    nl = str2double(answer{2});
end
cpic = latin2hieroglyph(str,nl,0);
mpic = cpic{1};
[b,a,~] = size(mpic);
if a > b
    lw = floor(b/16);
    cpic = cartouche(mpic,-lw);
else
    lw = floor(a/16);
    cpic = cartouche(mpic, lw);
end
mpic = cpic{1};
%adjust and show image
offset = 10;
figure('name','Egyptian Hieroglyphs (with cartouche)',...
    'numbertitle','off','menubar','none','resize','off');
imshow(mpic);
hf = gcf;
ha = gca;
set(ha,'unit','pixels');
fpos = get(hf,'position');
apos = get(ha,'position');
set(hf,'position',[fpos(1:2) apos(3:4)+2*offset]);
set(ha,'position',[offset offset apos(3:4)]);

%save image
answer = inputdlg({'File name:','Save as type:'},...
    'Save file',...
    1,{'HIEROGLYPH','.bmp'},'on');
if ~isempty(answer)
    filename = uigetdir(matlabroot,'Select Directory to Save');
    fname = answer{1};
    ftype = answer{2};
    if ftype ~= '.'
        ftype = ['.' ftype];
    end
    if ischar(filename) && exist(filename,'dir')
        imwrite(mpic,fullfile(filename,[fname ftype]));
    end
end

end

Contact us