bmp2ssd1306 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitattributes +1 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE +24 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bmp2ssd1306.gemspec +28 -0
- data/exe/bmp2ssd1306 +39 -0
- data/lib/bmp2ssd1306.rb +30 -0
- data/lib/bmp2ssd1306/version.rb +3 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7d7d0c1d6e0246d0f7523a60ebf336cbef7edf2e
|
4
|
+
data.tar.gz: 5c63e97da33e0e9844aa84d639ae3815490da93f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e1a6a252a0b6ee77426ea5742ffb177482e4c19a285d7d1179d6daf63d83c07d2d5f689f9db742ed0572ce247fed8d66e7bcc924462bd571c0723fd49be53fb
|
7
|
+
data.tar.gz: '0749363a0bd5150b6acc105bd4c792364bb5ddfd8a0124878956ff7205b75b08ec439827e107efbb51319e7ec620e6dbf41f38e8e14b5dfbe57a3ae4269ed1fc'
|
data/.gitattributes
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.img binary
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2017, Naoto Takai
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
* Neither the name of the <organization> nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# BMP2SSD1306
|
2
|
+
|
3
|
+
BMP2SSD1306 is an image converter for SSD1306 OLED. It converts the BMP image into the file that has the memory layout of the SSD1306.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
Ruby 2.4 or higher.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install it yourself as:
|
12
|
+
|
13
|
+
```
|
14
|
+
$ gem install bmp2ssd1306
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Please specify the BMP file to convert from the command line.
|
20
|
+
|
21
|
+
```
|
22
|
+
$ bmp2ssd1306 t-rex1.bmp t-rex2.bmp
|
23
|
+
$ ls *.img
|
24
|
+
t-rex1.img t-rex2.img
|
25
|
+
```
|
26
|
+
|
27
|
+
## Options
|
28
|
+
|
29
|
+
```
|
30
|
+
Usage: bmp2ssd1306 [options] <image>...
|
31
|
+
-v, --verbose Show the files being worked on
|
32
|
+
-o, --output DIR Write images converted to DIR
|
33
|
+
-s, --suffix SUFFIX Change the suffix from .img to SUFFIX
|
34
|
+
```
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/takai/bmp2ssd1306.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bmp2ssd1306"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bmp2ssd1306.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bmp2ssd1306/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'bmp2ssd1306'
|
8
|
+
spec.version = BMP2SSD1306::VERSION
|
9
|
+
spec.authors = ['Naoto Takai']
|
10
|
+
spec.email = ['takai@recompile.net']
|
11
|
+
|
12
|
+
spec.summary = 'BMP2SSD1306 is an image converter for SSD1306 OLED.'
|
13
|
+
spec.description = 'BMP2SSD1306 is an image converter for SSD1306 OLED. It converts the BMP image into the file that has the memory layout of the SSD1306.'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'rmagick'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
end
|
data/exe/bmp2ssd1306
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'bmp2ssd1306'
|
5
|
+
|
6
|
+
Version = BMP2SSD1306::VERSION
|
7
|
+
|
8
|
+
options = { output: '.', verbose: false, suffix: '.img' }
|
9
|
+
|
10
|
+
opt = OptionParser.new
|
11
|
+
opt.on('-v', '--verbose', 'Show the files being worked on') do |v|
|
12
|
+
options[:verbose] = v
|
13
|
+
end
|
14
|
+
opt.on('-o DIR', '--output', 'Write images converted to DIR') do |v|
|
15
|
+
options[:output] = v
|
16
|
+
end
|
17
|
+
opt.on('-s SUFFIX', '--suffix', 'Change the suffix from .img to SUFFIX') do |v|
|
18
|
+
options[:suffix] = v
|
19
|
+
end
|
20
|
+
opt.banner += ' <image>...'
|
21
|
+
opt.parse!(ARGV)
|
22
|
+
|
23
|
+
if ARGV.length == 0
|
24
|
+
puts(opt.help)
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
ARGV.each do |path|
|
29
|
+
basename = File.basename(path, '.bmp')
|
30
|
+
target = File.join(options[:output], "#{basename}#{options[:suffix]}")
|
31
|
+
|
32
|
+
File.open(target, 'w') do |file|
|
33
|
+
file.write(BMP2SSD1306.convert(path))
|
34
|
+
end
|
35
|
+
|
36
|
+
if options[:verbose]
|
37
|
+
puts("Converted: #{File.expand_path(path)} -> #{File.expand_path(target)}")
|
38
|
+
end
|
39
|
+
end
|
data/lib/bmp2ssd1306.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rmagick'
|
2
|
+
|
3
|
+
require "bmp2ssd1306/version"
|
4
|
+
|
5
|
+
module BMP2SSD1306
|
6
|
+
def convert(path)
|
7
|
+
buff = ''
|
8
|
+
|
9
|
+
image = Magick::Image.read(path).first
|
10
|
+
cols = image.columns
|
11
|
+
rows = image.rows
|
12
|
+
|
13
|
+
(0...rows).step(8) do |row|
|
14
|
+
(0...cols).each do |col|
|
15
|
+
byte = []
|
16
|
+
(0...8).each do |cur|
|
17
|
+
pixel = image.pixel_color(col, row + cur)
|
18
|
+
bit = pixel.red > 0 && pixel.green > 0 && pixel.blue > 0 ? 0 : 1
|
19
|
+
|
20
|
+
byte << bit
|
21
|
+
end
|
22
|
+
buff << [byte.join].pack('b*')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
buff
|
27
|
+
end
|
28
|
+
|
29
|
+
module_function :convert
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bmp2ssd1306
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naoto Takai
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rmagick
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: BMP2SSD1306 is an image converter for SSD1306 OLED. It converts the BMP
|
84
|
+
image into the file that has the memory layout of the SSD1306.
|
85
|
+
email:
|
86
|
+
- takai@recompile.net
|
87
|
+
executables:
|
88
|
+
- bmp2ssd1306
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitattributes"
|
93
|
+
- ".gitignore"
|
94
|
+
- ".rspec"
|
95
|
+
- ".travis.yml"
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- bin/console
|
101
|
+
- bin/setup
|
102
|
+
- bmp2ssd1306.gemspec
|
103
|
+
- exe/bmp2ssd1306
|
104
|
+
- lib/bmp2ssd1306.rb
|
105
|
+
- lib/bmp2ssd1306/version.rb
|
106
|
+
homepage:
|
107
|
+
licenses: []
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.6.11
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: BMP2SSD1306 is an image converter for SSD1306 OLED.
|
129
|
+
test_files: []
|