Permalink
Browse files

Whitespace cleanup

  • Loading branch information...
1 parent c0b9e7b commit c7d86152f0e450aee1be7855d2120d22df477cb0 David Reid committed Feb 24, 2011
Showing with 1,351 additions and 1,383 deletions.
  1. +34 −35 include/erl_img.hrl
  2. +5 −9 src/adler.erl
  3. +86 −86 src/erl_img.erl
  4. +44 −49 src/exif.erl
  5. +60 −60 src/gpsinfo.erl
  6. +47 −54 src/image_bmp.erl
  7. +289 −295 src/image_gif.erl
  8. +149 −149 src/image_jpeg.erl
  9. +161 −162 src/image_png.erl
  10. +293 −293 src/image_tiff.erl
  11. +74 −76 src/image_x_xpixmap.erl
  12. +92 −95 src/lzw.erl
  13. +5 −6 src/mktab.erl
  14. +12 −14 src/tiff.hrl
View
@@ -1,5 +1,5 @@
%%
-%% image format A R G B
+%% image format A R G B
%% pixel data 16 16 16 16
%%
-ifndef(__ERL_IMG_HRL__).
@@ -28,54 +28,53 @@
5 -> <<0,0,0,0,0>>;
6 -> <<0,0,0,0,0,0>>;
7 -> <<0,0,0,0,0,0,0>>;
- N -> list_to_binary(lists:duplicate(N,0))
- end).
+ N -> list_to_binary(lists:duplicate(N,0))
+ end).
-define(IMAGE_TYPES, [?IMAGE_JPEG,
- ?IMAGE_TIFF,
+ ?IMAGE_TIFF,
?IMAGE_GIF,
?IMAGE_PNG,
?IMAGE_BMP,
?IMAGE_X_XPIXMAP,
?VIDEO_MPEG]).
-record(erl_pixmap,
- {
- top = 0,
- left = 0,
- width = 0,
- height = 0,
- palette, %% list [{R,G,B}]
- format, %% pixmap format
- attributes = [], %% extension codes
- pixels = [] %% [ {Ri,binary(Row)} ]
- }).
+ {
+ top = 0,
+ left = 0,
+ width = 0,
+ height = 0,
+ palette, %% list [{R,G,B}]
+ format, %% pixmap format
+ attributes = [], %% extension codes
+ pixels = [] %% [ {Ri,binary(Row)} ]
+ }).
-record(erl_image,
- {
- type, %% module name of image handler
- name, %% Image name (no path)
- filename, %% Full filename
- size, %% File size
- extension, %% extension used
- mtime, %% file creation date {{YYYY,MM,DD},{HH,MM,SS}}
+ {
+ type, %% module name of image handler
+ name, %% Image name (no path)
+ filename, %% Full filename
+ size, %% File size
+ extension, %% extension used
+ mtime, %% file creation date {{YYYY,MM,DD},{HH,MM,SS}}
itime, %% image creation date {{YYYY,MM,DD},{HH,MM,SS}}
comment = "", %% image comment (if present)
- format, %% pixel format:
- %% gray4, gray8,
- %% palette4, palette8
- %% b8g8r8 r8g8b8 r8g8b8a8
- width, %% Image width
- height, %% Image height
- depth, %% Image depth
- bytes_pp = 3, %% bytes per pixel
- alignment = 1,
+ format, %% pixel format:
+ %% gray4, gray8,
+ %% palette4, palette8
+ %% b8g8r8 r8g8b8 r8g8b8a8
+ width, %% Image width
+ height, %% Image height
+ depth, %% Image depth
+ bytes_pp = 3, %% bytes per pixel
+ alignment = 1,
attributes = [], %% list of attributes [{atom(Key),term(Value)}]
- order, %% sample order left_to_right or right_to_left
- palette, %% list [{R,G,B}]
- pixmaps = [] %% [#erl_pixmap]
- }).
+ order, %% sample order left_to_right or right_to_left
+ palette, %% list [{R,G,B}]
+ pixmaps = [] %% [#erl_pixmap]
+ }).
-endif.
-
View
@@ -7,7 +7,7 @@
-export([adler32/1, adler32/2]).
--define(BASE, 65521). %% largest prime smaller than 65536
+-define(BASE, 65521). %% largest prime smaller than 65536
-define(NMAX, 5552).
adler32(Bin) ->
@@ -25,20 +25,16 @@ adler_n(Adler, Offs, S1, S2, Bin, 0) ->
Len = size(Bin) - Offs,
K = if Len < ?NMAX -> Len; true -> ?NMAX end,
if K == 0 ->
- (S2 bsl 16) bor S1;
+ (S2 bsl 16) bor S1;
true ->
- adler_n(Adler, Offs, S11, S12, Bin, K)
+ adler_n(Adler, Offs, S11, S12, Bin, K)
end;
adler_n(Adler, Offs, S1, S2, Bin, I) when I >= 8 ->
<<_:Offs/binary, C0,C1,C2,C3,C4,C5,C6,C7,_/binary>> = Bin,
S11 = S1+C0,
adler_n(Adler, Offs+8,
- S11+C1+C2+C3+C4+C5+C6+C7,
- S2+8*S11+7*C1+6*C2+5*C3+4*C4+3*C5+2*C6+C7, Bin, I-8);
+ S11+C1+C2+C3+C4+C5+C6+C7,
+ S2+8*S11+7*C1+6*C2+5*C3+4*C4+3*C5+2*C6+C7, Bin, I-8);
adler_n(Adler, Offs, S1, S2, Bin, I) ->
<<_:Offs/binary, C0,_/binary>> = Bin,
adler_n(Adler, Offs+1, S1+C0, S2+S1+C0, Bin, I-1).
-
-
-
-
View
@@ -39,55 +39,55 @@ nib(N) -> (N-10)+$A.
%% Check a header of least 64 bytes
magic([Type|Ts], Bin) ->
case apply(Type, magic, [Bin]) of
- true -> {true, Type };
- false -> magic(Ts, Bin)
+ true -> {true, Type };
+ false -> magic(Ts, Bin)
end;
-magic([], _Bin) ->
+magic([], _Bin) ->
false.
%% Read file mtime information
file_info(File, _IMG) ->
case file:read_file_info(File) of
- {ok, Info} when Info#file_info.type == regular,
- Info#file_info.size > 0 ->
- {ok, {Info#file_info.mtime,Info#file_info.size}};
- {ok, _Other} ->
- {error, bad_file};
- Error ->
- Error
+ {ok, Info} when Info#file_info.type == regular,
+ Info#file_info.size > 0 ->
+ {ok, {Info#file_info.mtime,Info#file_info.size}};
+ {ok, _Other} ->
+ {error, bad_file};
+ Error ->
+ Error
end.
read_magic_info(Fd) ->
file:position(Fd, 0),
case file:read(Fd, 64) of
- {ok, Bin} ->
- case magic(?IMAGE_TYPES, Bin) of
- {true, Type} ->
- read_info(Type, Fd);
- false ->
- {error, not_supported}
- end;
- Error ->
- Error
+ {ok, Bin} ->
+ case magic(?IMAGE_TYPES, Bin) of
+ {true, Type} ->
+ read_info(Type, Fd);
+ false ->
+ {error, not_supported}
+ end;
+ Error ->
+ Error
end.
-
+
magic_info(File) ->
case file:open(File,[raw,binary,read]) of
- {ok,Fd} ->
- Res = read_magic_info(Fd),
- file:close(Fd),
- case Res of
- {ok,IMG} ->
- {ok,IMG#erl_image { filename = File,
- name = filename:basename(File) }};
- Error ->
- Error
- end;
- Error -> Error
+ {ok,Fd} ->
+ Res = read_magic_info(Fd),
+ file:close(Fd),
+ case Res of
+ {ok,IMG} ->
+ {ok,IMG#erl_image { filename = File,
+ name = filename:basename(File) }};
+ Error ->
+ Error
+ end;
+ Error -> Error
end.
@@ -101,61 +101,61 @@ extensions(IMG) ->
read_file_info(File) ->
case file_info(File, #erl_image { }) of
- {ok, {MTime,Size}} ->
- case magic_info(File) of
- {ok,IMG} ->
- {ok,IMG#erl_image { mtime = MTime,
- size = Size}};
- Error ->
- Error
- end;
- Error -> Error
+ {ok, {MTime,Size}} ->
+ case magic_info(File) of
+ {ok,IMG} ->
+ {ok,IMG#erl_image { mtime = MTime,
+ size = Size}};
+ Error ->
+ Error
+ end;
+ Error -> Error
end.
load(File) ->
case file:open(File, [raw, binary, read]) of
- {ok,Fd} ->
- Res = case read_magic_info(Fd) of
- {ok, IMG} ->
- read(Fd, IMG#erl_image { filename = File });
- Error ->
- Error
- end,
- file:close(Fd),
- Res;
- Error -> Error
+ {ok,Fd} ->
+ Res = case read_magic_info(Fd) of
+ {ok, IMG} ->
+ read(Fd, IMG#erl_image { filename = File });
+ Error ->
+ Error
+ end,
+ file:close(Fd),
+ Res;
+ Error -> Error
end.
save(IMG) ->
save(IMG#erl_image.filename, IMG).
save(File, IMG) ->
case file:open(File, [raw, binary, write]) of
- {ok,Fd} ->
- Res = write(Fd, IMG),
- file:close(Fd),
- Res;
- Error ->
- Error
+ {ok,Fd} ->
+ Res = write(Fd, IMG),
+ file:close(Fd),
+ Res;
+ Error ->
+ Error
end.
to_binary(IMG) ->
case file:open(<<>>, [ram, binary, write]) of
- {ok,Fd} ->
- ok = write(Fd, IMG),
- case ram_file:get_file_close(Fd) of
- {ok, Data} ->
- {ok,Data};
- Error ->
- Error
- end;
- Error ->
- Error
+ {ok,Fd} ->
+ ok = write(Fd, IMG),
+ case ram_file:get_file_close(Fd) of
+ {ok, Data} ->
+ {ok,Data};
+ Error ->
+ Error
+ end;
+ Error ->
+ Error
end.
-
-
+
+
read_info(Type, Fd) ->
file:position(Fd, 0),
@@ -164,7 +164,7 @@ read_info(Type, Fd) ->
write_info(Type, Fd, IMG) ->
file:position(Fd, 0),
apply(Type, write_info, [Fd,IMG]).
-
+
read(Fd,IMG) ->
file:position(Fd, 0),
apply(IMG#erl_image.type, read, [Fd,IMG]).
@@ -181,34 +181,34 @@ attribute(IMG, Key) ->
attribute(IMG, Key, Default) ->
case lists:keysearch(Key, 1, IMG#erl_image.attributes) of
- {value, {_, Value}} -> Value;
- false -> Default
+ {value, {_, Value}} -> Value;
+ false -> Default
end.
-set_attribute(IMG, Key, Value) ->
- As = IMG#erl_image.attributes,
+set_attribute(IMG, Key, Value) ->
+ As = IMG#erl_image.attributes,
As1 = case lists:keysearch(Key, 1, As) of
- false -> [{Key,Value}|As];
- {value,_} ->
- lists:keyreplace(Key, 1, As, {Key,Value})
- end,
+ false -> [{Key,Value}|As];
+ {value,_} ->
+ lists:keyreplace(Key, 1, As, {Key,Value})
+ end,
IMG#erl_image { attributes = As1 }.
-
+
dir_info(Dir) ->
case file:list_dir(Dir) of
- {ok, Listing} ->
- dir_list(Listing,Dir);
- Error ->
- Error
+ {ok, Listing} ->
+ dir_list(Listing,Dir);
+ Error ->
+ Error
end.
dir_list([File|Fs], Dir) ->
case read_file_info(filename:join(Dir, File)) of
- {ok,IMG} ->
- [IMG|dir_list(Fs, Dir)];
- _Error ->
- dir_list(Fs, Dir)
+ {ok,IMG} ->
+ [IMG|dir_list(Fs, Dir)];
+ _Error ->
+ dir_list(Fs, Dir)
end;
dir_list([], _Dir) ->
[].
Oops, something went wrong.

0 comments on commit c7d8615

Please sign in to comment.