Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TSG QC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
US191
TSG QC
Commits
636ffab3
Commit
636ffab3
authored
7 years ago
by
jacques.grelet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
remove iconRead.m
parent
3db777cb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tsg_util/iconRead.m
+0
-75
0 additions, 75 deletions
tsg_util/iconRead.m
with
0 additions
and
75 deletions
tsg_util/iconRead.m
deleted
100644 → 0
+
0
−
75
View file @
3db777cb
function
cdata
=
iconRead
(
filename
,
guessalpha
)
% ICONREAD read an image file and convert it to CData for a HG icon.
%
% CDATA=ICONREAD(FILENAME)
% Read an image file and convert it to CData with automatic transparency
% handling. If the image has transparency data, PNG files sometimes do,
% the transparency data is used. If the image has no CData, the top left
% pixel is treated as the transparent color.
%
% CDATA=ICONREAD(FILENAME, FALSE)
% Same as above but supress the usage of the top left pixel for images
% with no transparency data. This may require the caller to handle the
% transparency explicitly. View the contents of this m-file for an
% example of how to handle transparency.
%
% Example:
%
% icon = fullfile(matlabroot,'toolbox','matlab','icons','matlabicon.gif');
% uitoggletool('CData',iconread(icon));
%
% See also IMREAD.
% Copyright 1984-2006 The MathWorks, Inc.
if
nargin
<
2
guessalpha
=
true
;
end
[
p
,
f
,
ext
]
=
fileparts
(
filename
);
% if this is a mat-file, look for the varible cdata (or something like it)
if
isequal
(
lower
(
ext
),
'.mat'
)
cdata
=
[];
s
=
whos
(
'-file'
,
filename
);
for
i
=
1
:
length
(
s
)
if
~
isempty
(
strfind
(
lower
(
s
(
i
)
.
name
),
'cdata'
))
data
=
load
(
filename
,
s
(
i
)
.
name
);
cdata
=
data
.
(
s
(
i
)
.
name
);
end
end
return
end
[
cdata
,
map
,
alpha
]
=
imread
(
filename
);
if
isempty
(
cdata
)
return
;
end
if
isempty
(
map
)
% need to use doubles cuz nan's only work as doubles
cdata
=
double
(
cdata
);
cdata
=
cdata
/
255
;
else
cdata
=
ind2rgb
(
cdata
,
map
);
end
if
isempty
(
alpha
)
if
~
guessalpha
return
;
end
% guess the alpha pixel by using the top left pixel in the icon
ap1
=
cdata
(
1
,
1
,
1
);
ap2
=
cdata
(
1
,
1
,
2
);
ap3
=
cdata
(
1
,
1
,
3
);
alpha
=
cdata
(:,:,
1
)
==
ap1
&
cdata
(:,:,
2
)
==
ap2
&
cdata
(:,:,
3
)
==
ap3
;
alpha
=
~
alpha
;
end
% process alpha data
r
=
cdata
(:,:,
1
);
r
(
alpha
==
0
)
=
NaN
;
g
=
cdata
(:,:,
2
);
g
(
alpha
==
0
)
=
NaN
;
b
=
cdata
(:,:,
3
);
b
(
alpha
==
0
)
=
NaN
;
cdata
=
cat
(
3
,
r
,
g
,
b
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment