Skip to content

Commit cc62a93

Browse files
committed
Merge branch 'develop'
2 parents b4c7621 + 954b672 commit cc62a93

File tree

13 files changed

+217
-234
lines changed

13 files changed

+217
-234
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repositories {
1313
dependencies {
1414
testImplementation(kotlin("test"))
1515
implementation ("com.github.volta2030:delta:1.1.0")
16-
implementation ("com.github.Pascal-Institute:komat:1.9.1")
16+
implementation ("com.github.Pascal-Institute:komat:develop-SNAPSHOT")
1717
}
1818

1919
tasks.test {

src/main/kotlin/bumblebee/FileManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class FileManager {
3737
intToByteArray(imgPix.width, 4) +
3838
intToByteArray(imgPix.height, 4) +
3939
intToByteArray(imgPix.colorType.num, 1) +
40-
imgPix.mat.elements.map { it.toByte() }.toByteArray()
40+
imgPix.cube.toByteArray()
4141
File("$filePath.pix").writeBytes(byteArray)
4242
}
4343
else -> {}

src/main/kotlin/bumblebee/core/ImgInspector.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,25 @@ import bumblebee.color.GRAY
55
import bumblebee.color.RGB
66
import bumblebee.color.RGBA
77
import bumblebee.util.Converter.Companion.toHex
8-
import komat.space.Vect
98

109
class ImgInspector {
1110
companion object{
1211
fun getColorAt(imgPix: ImgPix, row : Int, col: Int) : Color {
1312
return when(imgPix.bytesPerPixel){
1413

15-
1-> GRAY((imgPix.mat[imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte).toUByte().toInt())
14+
1-> GRAY((imgPix.cube[imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()).toUByte().toInt())
1615

1716
3-> RGB(
18-
(imgPix.mat[0 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte).toUByte().toInt(),
19-
(imgPix.mat[1 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte).toUByte().toInt(),
20-
(imgPix.mat[2 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte).toUByte().toInt())
17+
(imgPix.cube[0 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()).toUByte().toInt(),
18+
(imgPix.cube[1 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()).toUByte().toInt(),
19+
(imgPix.cube[2 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()).toUByte().toInt())
2120

2221
//GBAR to RGBA
2322
4-> RGBA(
24-
(imgPix.mat[3 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte).toUByte().toInt(),
25-
(imgPix.mat[0 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte).toUByte().toInt(),
26-
(imgPix.mat[1 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte).toUByte().toInt(),
27-
(imgPix.mat[2 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte).toUByte().toInt()
23+
(imgPix.cube[3 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()).toUByte().toInt(),
24+
(imgPix.cube[0 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()).toUByte().toInt(),
25+
(imgPix.cube[1 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()).toUByte().toInt(),
26+
(imgPix.cube[2 + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()).toUByte().toInt()
2827
)
2928

3029
else->{
@@ -36,7 +35,7 @@ class ImgInspector {
3635
fun getHexStringAt(imgPix: ImgPix, row : Int, col : Int) : String{
3736
val vect = ByteArray(imgPix.bytesPerPixel)
3837
for (i : Int in 0 until imgPix.bytesPerPixel){
39-
vect[i] = imgPix.mat[i + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row] as Byte
38+
vect[i] = imgPix.cube[i + imgPix.bytesPerPixel * col + (imgPix.width * imgPix.bytesPerPixel) * row].toByte()
4039
}
4140
return vect.toHex()
4241
}

src/main/kotlin/bumblebee/core/ImgPix.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import bumblebee.color.Color
55
import bumblebee.type.*
66
import bumblebee.util.Histogram
77
import komat.Element
8-
import komat.space.Mat
8+
import komat.space.Cube
99
import java.awt.Dimension
1010
import java.awt.Graphics
1111
import java.awt.Image
@@ -34,33 +34,32 @@ import javax.swing.WindowConstants
3434
val bytesPerPixel : Int
3535
get() = metaData.colorType.bytesPerPixel
3636

37-
var mat = Mat(0,0, ByteArray(0))
38-
39-
operator fun get(i: Int, j: Int): Element {
40-
return mat.elements[i * mat.column + j]
41-
}
37+
//depth : row
38+
//row : column
39+
//column : color size
40+
var cube = Cube(0,0,0, Element(0.toByte()))
4241

4342
constructor(width: Int, height: Int, colorType: ColorType) : this() {
4443
metaData.width = width
4544
metaData.height = height
4645
metaData.colorType = colorType
47-
this.mat = Mat(width, height* colorType.bytesPerPixel, ByteArray(width * height * colorType.bytesPerPixel))
46+
cube = Cube(width, height, colorType.bytesPerPixel, Element(0.toByte()))
4847
}
4948

5049
constructor(filePath : String) : this() {
5150
val imgPix = FileManager.read(filePath)
5251
metaData.width = imgPix.width
5352
metaData.height = imgPix.height
5453
metaData.colorType = imgPix.colorType
55-
this.mat = imgPix.mat
54+
cube = imgPix.cube
5655
}
5756

5857
public override fun clone(): ImgPix {
5958
return super.clone() as ImgPix
6059
}
6160

6261
fun show(){
63-
val buffer = DataBufferByte(mat.elements.map { it.toByte() }.toByteArray(), mat.elements.size)
62+
val buffer = DataBufferByte(cube.toByteArray(), cube.elements.size)
6463

6564
val bufferedImage : BufferedImage
6665
when(colorType){

0 commit comments

Comments
 (0)