This repository has been archived by the owner on Dec 17, 2022. It is now read-only.
forked from mochi/erl_img
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ad1e703
Showing
33 changed files
with
3,978 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Image processing stuff (bmp, gif, jpeg, png, xpm, tiff, mpeg) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
%% | ||
%% image format A R G B | ||
%% pixel data 16 16 16 16 | ||
%% | ||
-ifndef(__ERL_IMG_HRL__). | ||
-define(__ERL_IMG_HRL__, true). | ||
|
||
-define(IMAGE_JPEG, image_jpeg). | ||
-define(IMAGE_TIFF, image_tiff). | ||
-define(IMAGE_GIF, image_gif). | ||
-define(IMAGE_PNG, image_png). | ||
-define(IMAGE_BMP, image_bmp). | ||
-define(IMAGE_X_XPIXMAP, image_x_xpixmap). | ||
-define(IMAGE_UNDEF, image_undef). | ||
-define(VIDEO_MPEG, video_mpeg). | ||
|
||
-define(PAD_Len(L,A), (((A)-((L) rem (A))) rem (A))). | ||
|
||
-define(PAD_Len8(L), ((8 - ((L) band 7)) band 7)). | ||
|
||
-define(PAD(L,A), | ||
case ?PAD4_Len(L,A) of | ||
0 -> <<>>; | ||
1 -> <<0>>; | ||
2 -> <<0,0>>; | ||
3 -> <<0,0,0>>; | ||
4 -> <<0,0,0,0>>; | ||
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). | ||
|
||
-define(IMAGE_TYPES, [?IMAGE_JPEG, | ||
?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)} ] | ||
}). | ||
|
||
|
||
-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}} | ||
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, | ||
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] | ||
}). | ||
|
||
-endif. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
EBIN = ../ebin | ||
ERLC = erlc | ||
ERLC_FLAGS = -I../include | ||
|
||
OBJS = $(EBIN)/image_bmp.beam \ | ||
$(EBIN)/image_x_xpixmap.beam \ | ||
$(EBIN)/image_png.beam \ | ||
$(EBIN)/image_gif.beam \ | ||
$(EBIN)/image_jpeg.beam \ | ||
$(EBIN)/image_tiff.beam \ | ||
$(EBIN)/image_undef.beam \ | ||
$(EBIN)/video_mpeg.beam \ | ||
$(EBIN)/exif.beam \ | ||
$(EBIN)/lzw.beam \ | ||
$(EBIN)/erl_img.beam | ||
|
||
|
||
debug: ERLC_FLAGS += -Ddebug | ||
|
||
|
||
all: $(OBJS) | ||
|
||
debug: all | ||
|
||
|
||
$(OBJS): ../include/erl_img.hrl | ||
|
||
$(EBIN)/image_tiff.beam: tiff.hrl | ||
$(EBIN)/image_jpeg.beam: jpeg.hrl exif.hrl | ||
$(EBIN)/exif.beam: exif.hrl | ||
|
||
$(EBIN)/%.beam: %.erl | ||
$(ERLC) $(ERLC_FLAGS) -o $(EBIN) $< | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
%%% File : adler.erl | ||
%%% Author : Tony Rogvall <tony@bit.hemma.se> | ||
%%% Description : adler checksum | ||
%%% Created : 8 Apr 2003 by Tony Rogvall <tony@bit.hemma.se> | ||
|
||
-module(adler). | ||
|
||
-export([adler32/1, adler32/2]). | ||
|
||
-define(BASE, 65521). %% largest prime smaller than 65536 | ||
-define(NMAX, 5552). | ||
|
||
adler32(Bin) -> | ||
adler32(0, Bin). | ||
|
||
|
||
adler32(Adler, Bin) -> | ||
S1 = Adler band 16#ffff, | ||
S2 = (Adler bsr 16) band 16#ffff, | ||
adler_n(Adler, 0, S1, S2, Bin, 0). | ||
|
||
adler_n(Adler, Offs, S1, S2, Bin, 0) -> | ||
S11 = S1 rem ?BASE, | ||
S12 = S2 rem ?BASE, | ||
Len = size(Bin) - Offs, | ||
K = if Len < ?NMAX -> Len; true -> ?NMAX end, | ||
if K == 0 -> | ||
(S2 bsl 16) bor S1; | ||
true -> | ||
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); | ||
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). | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
%% | ||
%% These are the functions that make the image api | ||
%% | ||
|
||
|
||
%% magic(Bin) -> true | false | ||
-export([magic/1]). | ||
|
||
%% mime_type() -> <mime-type> | ||
-export([mime_type/0]). | ||
|
||
%% extensions() -> [ ".<ext1>" ... ".<extn>"] | ||
-export([extensions/0]). | ||
|
||
%% read_info(Fd) -> {ok, #erl_img} | Error | ||
-export([read_info/1]). | ||
|
||
%% write_info(Fd, #erl_img) -> ok | Error | ||
-export([write_info/2]). | ||
|
||
%% read(Fd, #erl_img) -> {ok, #erl_img'} | Error | ||
%% read(Fd, #erl_img, RowFun, State) -> {ok, #erl_img'} | Error | ||
%% RowFun = fun(#erl_img, Row, RowNumber, RowFormat, St) -> St' | ||
%% | ||
-export([read/2, read/4]). | ||
|
||
%% write(Fd, #erl_img) -> ok | Error | ||
-export([write/2]). | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
-ifdef(debug). | ||
-define(dbg(Fmt,Args), io:format((Fmt),(Args))). | ||
-else. | ||
-define(dbg(Fmt,Args), ok). | ||
-endif. |
Oops, something went wrong.