Libraryless. Click here for Pure Java version (10926L/62K).
1 | static Image2B iBinaryImageToImage2B(IBinaryImage img) { |
2 | if (img == null) null; |
3 | if (img cast Image2B) ret img; |
4 | int w = img.getWidth(), h = img.getHeight(); |
5 | byte[] pixels = new[(w*h+7)/8]; |
6 | int i = 0; |
7 | for y to h: |
8 | for x to w: { |
9 | if (img.getBoolPixel(x, y)) |
10 | pixels[i/8] |= 1 << (i & 7); |
11 | i++; |
12 | } |
13 | |
14 | ret new Image2B(w, h, pixels); |
15 | } |
Began life as a copy of #1035818
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035822 |
Snippet name: | iBinaryImageToImage2B |
Eternal ID of this version: | #1035822/4 |
Text MD5: | cf4b3c8bea97f5ac4cc3948334d589d2 |
Transpilation MD5: | f70ed4079054318b5d3b8ee147c64512 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-01 23:50:48 |
Source code size: | 382 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 73 / 115 |
Version history: | 3 change(s) |
Referenced in: | [show references] |