Skip to content

Commit

Permalink
1.7.3 fixing bitmap writer (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejmalecki authored Jun 19, 2023
1 parent 2974268 commit 1732de6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGES.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
= Change log

1.7.3::
* `Image`: Fixing bitmap writer.

1.7.2::
* `Image`: Reducting resolution in both X and Y axes added to the image preprocessor.
* `Image`: Handling of both indexed and RGBA PNG files.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
allprojects {

group = "com.github.c64lib"
version = "1.7.2"
version = "1.7.3"

if (project.hasProperty(tagPropertyName)) {
version = project.property(tagPropertyName) ?: version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class C64CharsetWriter(private val project: Project) : WriteCharsetPort {
for (blockY in 0 until numBlocksY) {
for (blockX in 0 until numBlocksX) {
for (y in 0 until 8) {
val yOffset = (blockY * 8) * numBlocksX * 8
val yOffset = blockY * 8
val xOffset = blockX * 8

val byte =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ import org.mockito.Mockito
class C64CharsetWriterTest :
BehaviorSpec({
fun createTestImage(): Image {
val image = Image(16, 8)
val image = Image(16, 16)

// Draw some example pixels
image[0, 0] = Color(255, 255, 255, 255)
image[7, 0] = Color(255, 255, 255, 255)
image[15, 7] = Color(255, 255, 255, 255)
image[15, 15] = Color(255, 255, 255, 255)

return image
}
Expand All @@ -64,9 +65,10 @@ class C64CharsetWriterTest :
Then("the resulting file should have the correct size and data") {
val charsetData = readCharsetData(outputFile)

charsetData.size shouldBe 16
charsetData.size shouldBe 32
charsetData[0] shouldBe 0b10000001.toByte()
charsetData[15] shouldBe 0b00000001.toByte()
charsetData[31] shouldBe 0b00000001.toByte()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class Image(val width: Int, val height: Int) {
private val pixels = Array(height) { Array(width) { Color(0, 0, 0, 255) } }

operator fun get(x: Int, y: Int): Color {
require(x in 0 until width) { "x coordinate out of bounds" }
require(y in 0 until height) { "y coordinate out of bounds" }
require(x in 0 until width) { "x coordinate out of bounds: $x >= $width" }
require(y in 0 until height) { "y coordinate out of bounds: $y >= $height" }
return pixels[y][x]
}

operator fun set(x: Int, y: Int, color: Color) {
require(x in 0 until width) { "x coordinate out of bounds" }
require(y in 0 until height) { "y coordinate out of bounds" }
require(x in 0 until width) { "x coordinate out of bounds: $x >= $width" }
require(y in 0 until height) { "y coordinate out of bounds: $y >= $height" }
pixels[y][x] = color
}

Expand Down

0 comments on commit 1732de6

Please sign in to comment.