png2swf 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ *.o
4
+ *.so
5
+ Gemfile.lock
6
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in png2swf.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
File without changes
@@ -0,0 +1,157 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = .
7
+ topdir = /home/maedana/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/i686-linux
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+ exec_prefix = $(prefix)
11
+ prefix = $(DESTDIR)/home/maedana/.rvm/rubies/ruby-1.8.7-p334
12
+ sharedstatedir = $(prefix)/com
13
+ mandir = $(datarootdir)/man
14
+ psdir = $(docdir)
15
+ oldincludedir = $(DESTDIR)/usr/include
16
+ localedir = $(datarootdir)/locale
17
+ bindir = $(exec_prefix)/bin
18
+ libexecdir = $(exec_prefix)/libexec
19
+ sitedir = $(libdir)/ruby/site_ruby
20
+ htmldir = $(docdir)
21
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
22
+ includedir = $(prefix)/include
23
+ infodir = $(datarootdir)/info
24
+ vendorlibdir = $(vendordir)/$(ruby_version)
25
+ sysconfdir = $(prefix)/etc
26
+ libdir = $(exec_prefix)/lib
27
+ sbindir = $(exec_prefix)/sbin
28
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
29
+ docdir = $(datarootdir)/doc/$(PACKAGE)
30
+ dvidir = $(docdir)
31
+ vendordir = $(libdir)/ruby/vendor_ruby
32
+ datarootdir = $(prefix)/share
33
+ pdfdir = $(docdir)
34
+ archdir = $(rubylibdir)/$(arch)
35
+ sitearchdir = $(sitelibdir)/$(sitearch)
36
+ datadir = $(datarootdir)
37
+ localstatedir = $(prefix)/var
38
+ sitelibdir = $(sitedir)/$(ruby_version)
39
+
40
+ CC = gcc
41
+ LIBRUBY = $(LIBRUBY_SO)
42
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
+ LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
44
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
45
+
46
+ RUBY_EXTCONF_H =
47
+ CFLAGS = -fPIC -g -O2 -fPIC $(cflags) -Wall
48
+ INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
49
+ DEFS = -D_FILE_OFFSET_BITS=64
50
+ CPPFLAGS = $(DEFS) $(cppflags)
51
+ CXXFLAGS = $(CFLAGS)
52
+ ldflags = -L. -rdynamic -Wl,-export-dynamic
53
+ dldflags =
54
+ archflag =
55
+ DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
+ LDSHARED = $(CC) -shared
57
+ AR = ar
58
+ EXEEXT =
59
+
60
+ RUBY_INSTALL_NAME = ruby
61
+ RUBY_SO_NAME = ruby
62
+ arch = i686-linux
63
+ sitearch = i686-linux
64
+ ruby_version = 1.8
65
+ ruby = /home/maedana/.rvm/rubies/ruby-1.8.7-p334/bin/ruby
66
+ RUBY = $(ruby)
67
+ RM = rm -f
68
+ MAKEDIRS = mkdir -p
69
+ INSTALL = /usr/bin/install -c
70
+ INSTALL_PROG = $(INSTALL) -m 0755
71
+ INSTALL_DATA = $(INSTALL) -m 644
72
+ COPY = cp
73
+
74
+ #### End of system configuration section. ####
75
+
76
+ preload =
77
+
78
+ libpath = . $(libdir)
79
+ LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir)
80
+ DEFFILE =
81
+
82
+ CLEANFILES = mkmf.log
83
+ DISTCLEANFILES =
84
+
85
+ extout =
86
+ extout_prefix =
87
+ target_prefix = /png2swf
88
+ LOCAL_LIBS =
89
+ LIBS = $(LIBRUBYARG_SHARED) -lrt -ldl -lcrypt -lm -lc
90
+ SRCS = define_bits_lossless2.c
91
+ OBJS = define_bits_lossless2.o
92
+ TARGET = define_bits_lossless2
93
+ DLLIB = $(TARGET).so
94
+ EXTSTATIC =
95
+ STATIC_LIB =
96
+
97
+ BINDIR = $(bindir)
98
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
101
+
102
+ TARGET_SO = $(DLLIB)
103
+ CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
104
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
+
106
+ all: $(DLLIB)
107
+ static: $(STATIC_LIB)
108
+
109
+ clean:
110
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
+
112
+ distclean: clean
113
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
115
+
116
+ realclean: distclean
117
+ install: install-so install-rb
118
+
119
+ install-so: $(RUBYARCHDIR)
120
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
121
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
122
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
123
+ install-rb: pre-install-rb install-rb-default
124
+ install-rb-default: pre-install-rb-default
125
+ pre-install-rb: Makefile
126
+ pre-install-rb-default: Makefile
127
+ $(RUBYARCHDIR):
128
+ $(MAKEDIRS) $@
129
+
130
+ site-install: site-install-so site-install-rb
131
+ site-install-so: install-so
132
+ site-install-rb: install-rb
133
+
134
+ .SUFFIXES: .c .m .cc .cxx .cpp .C .o
135
+
136
+ .cc.o:
137
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
138
+
139
+ .cxx.o:
140
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
141
+
142
+ .cpp.o:
143
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
144
+
145
+ .C.o:
146
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
147
+
148
+ .c.o:
149
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
150
+
151
+ $(DLLIB): $(OBJS) Makefile
152
+ @-$(RM) $@
153
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
154
+
155
+
156
+
157
+ $(OBJS): ruby.h defines.h
@@ -0,0 +1,3 @@
1
+ require 'mkmf'
2
+ $CFLAGS << ' -Wall'
3
+ create_makefile('png2swf/oily_png2swf')
@@ -0,0 +1,50 @@
1
+ #include <stdio.h>
2
+ #include <ruby.h>
3
+
4
+ int red(unsigned long color) {
5
+ return (color & 0xff000000) >> 24;
6
+ }
7
+
8
+ int green(unsigned long color) {
9
+ return (color & 0x00ff0000) >> 16;
10
+ }
11
+
12
+ int blue(unsigned long color) {
13
+ return (color & 0x0000ff00) >> 8;
14
+ }
15
+
16
+ int alpha(unsigned long color) {
17
+ return color & 0x000000ff;
18
+ }
19
+
20
+ VALUE bitmap_data(VALUE vself, VALUE vpixels) {
21
+ int pixel_size = RARRAY(vpixels)->len;
22
+ unsigned long color;
23
+ int a; // alpha for swf bitmap data
24
+ unsigned char r, g, b; // red, green, blue for swf bitmap data
25
+ unsigned char data[pixel_size * 4]; // argb for swf bitmap data
26
+ int i;
27
+ int data_index = 0;
28
+ for (i=0; i<pixel_size; i++) {
29
+ color = NUM2ULONG((RARRAY(vpixels)->ptr[i]));
30
+ a = alpha(color);
31
+ r = (unsigned char)((red(color) * a) / 255.0);
32
+ g = (unsigned char)((green(color) * a) / 255.0);
33
+ b = (unsigned char)((blue(color)) * a / 255.0);
34
+ data[data_index] = a;
35
+ data[data_index+1] = r;
36
+ data[data_index+2] = g;
37
+ data[data_index+3] = b;
38
+ data_index+=4;
39
+ }
40
+ VALUE vdata = rb_str_new(0,0); // 戻り値用にrubyの空文字を作成 vdata = '' と同じ
41
+ rb_str_cat(vdata, data, (pixel_size * 4)); // rubyの文字列としてバイナリデータを連結
42
+ return vdata;
43
+ }
44
+
45
+ Init_oily_png2swf() {
46
+ VALUE Png2swf = rb_define_module("OilyPng2swf");
47
+
48
+ VALUE DefineBitsLossless2 = rb_define_module_under(Png2swf, "DefineBitsLossless2");
49
+ rb_define_method(DefineBitsLossless2, "bitmap_data", bitmap_data, 1);
50
+ }
@@ -0,0 +1,22 @@
1
+ require 'base64'
2
+ require 'chunky_png'
3
+ require 'png2swf/oily_png2swf'
4
+
5
+ module Png2swf
6
+ class DefineBitsLossless2
7
+ extend OilyPng2swf::DefineBitsLossless2
8
+
9
+ def self.image2data_from_file filepath
10
+ image2data(ChunkyPNG::Image.from_file(filepath))
11
+ end
12
+
13
+ def self.image2data_from_blob blob
14
+ image2data(ChunkyPNG::Image.from_blob(blob))
15
+ end
16
+
17
+ def self.image2data image
18
+ zlib_bitmap_data = Zlib::Deflate.deflate(bitmap_data(image.pixels))
19
+ ::Base64.encode64(zlib_bitmap_data).split.join
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Png2swf
2
+ VERSION = "0.0.1"
3
+ end
data/lib/png2swf.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "png2swf/version"
2
+
3
+ module Png2swf
4
+ end
data/png2swf.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "png2swf/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "png2swf"
7
+ s.rubyforge_project = "png2swf"
8
+ s.version = Png2swf::VERSION
9
+ s.authors = ["Naoki Maeda"]
10
+ s.email = ["maeda.na@gmail.com"]
11
+ s.homepage = "http://wiki.github.com/maedana/png2swf"
12
+ s.summary = %q{Encode png for swfmill bitmap formats.}
13
+ s.description = %q{Encode png for swfmill bitmap formats.}
14
+
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+
20
+ s.extensions = ["ext/oily_png2swf/extconf.rb"]
21
+ s.require_paths = ["lib", "ext"]
22
+
23
+ s.add_runtime_dependency('chunky_png', '~> 1.2.1')
24
+
25
+ s.add_development_dependency('rake')
26
+ s.add_development_dependency('rake-compiler')
27
+ s.add_development_dependency('rspec', '~> 2')
28
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: png2swf
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Naoki Maeda
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-20 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: chunky_png
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 29
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 1
34
+ version: 1.2.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rake-compiler
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rspec
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ hash: 7
74
+ segments:
75
+ - 2
76
+ version: "2"
77
+ type: :development
78
+ version_requirements: *id004
79
+ description: Encode png for swfmill bitmap formats.
80
+ email:
81
+ - maeda.na@gmail.com
82
+ executables: []
83
+
84
+ extensions:
85
+ - ext/oily_png2swf/extconf.rb
86
+ extra_rdoc_files: []
87
+
88
+ files:
89
+ - .gitignore
90
+ - Gemfile
91
+ - Rakefile
92
+ - ext/oily_png2swf/MANIFEST
93
+ - ext/oily_png2swf/Makefile
94
+ - ext/oily_png2swf/extconf.rb
95
+ - ext/oily_png2swf/oily_png2swf_ext.c
96
+ - lib/png2swf.rb
97
+ - lib/png2swf/define_bits_lossless2.rb
98
+ - lib/png2swf/version.rb
99
+ - png2swf.gemspec
100
+ has_rdoc: true
101
+ homepage: http://wiki.github.com/maedana/png2swf
102
+ licenses: []
103
+
104
+ post_install_message:
105
+ rdoc_options: []
106
+
107
+ require_paths:
108
+ - lib
109
+ - ext
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ hash: 3
125
+ segments:
126
+ - 0
127
+ version: "0"
128
+ requirements: []
129
+
130
+ rubyforge_project: png2swf
131
+ rubygems_version: 1.5.0
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Encode png for swfmill bitmap formats.
135
+ test_files: []
136
+