try
    load mandrill
    [row, col] = size(X);
    r = [0, 0, row, col];
    [windowPtr, rect] = Screen('OpenWindow', 0);
    r = CenterRect(r, rect);
    X2=ind2rgb(X,map);
    X2=X2*256;
    pic = Screen('MakeTexture', windowPtr, X);
    Screen('DrawTexture', windowPtr, pic, [], r, 45);
    Screen('Flip', windowPtr);
    KbWait;
    Screen('CloseAll');
catch
    Screen('CloseAll')
    rethrow(lasterror)
end