Code covered by the BSD License  

Highlights from
Load Adobe Swatch Exchange as colormap

image thumbnail
from Load Adobe Swatch Exchange as colormap by Nick Gravish
Loads an Adobe Swatch Exchange as a colormap.

load_ASE(fname)
function colors = load_ASE(fname)
%
% This function loads an Adobe Swatch Exchange file, like those exported
% from Photoshop/Illustrator or created on http://kuler.adobe.com/
%
% ASE files should be in RGB format. 
%
% Function outputs a 255 color RGB colormap 
%

% fname = 'antspaper.ase';

f = fopen(fname);
data = fread(f);
fclose(f);

% find all locations in file with RGB delimiter
locs = [];
for ii=1:length(data)-4
    if(sum(abs(cast(data(ii:ii+2),'char')-['R';'G';'B']))==0)
        locs(end+1) = ii
    end
end

colors = [];

for ii=locs

    r = [];
    g = [];
    b = [];
    for kk=0:3
        tmp = dec2hex(data(ii+4+kk),2);
        r = [r tmp];
        
        tmp = dec2hex(data(ii+8+kk),2);
        g = [g tmp];
        
        tmp = dec2hex(data(ii+12+kk),2);
        b = [b tmp];
        
    end
    colors(end+1,:) = [singlehex2num(r) singlehex2num(g) singlehex2num(b)]; 
end

colors = interp2(1:3, 1:5, colors, 1:3',linspace(1,5,255)');


%%

Contact us