Stefan Oltmann
01/29/2024, 9:36 AMJoel Denke
01/29/2024, 2:00 PMStefan Oltmann
01/29/2024, 2:04 PMKirill Grouchnikov
01/29/2024, 2:04 PMKirill Grouchnikov
01/29/2024, 2:05 PMStefan Oltmann
01/29/2024, 2:05 PMKirill Grouchnikov
01/29/2024, 2:05 PMval filename = Paths.get("/my/big.webp").normalize().toAbsolutePath()
.toString()
println("Filename = $filename")
val time0 = System.nanoTime()
val codec = Codec.makeFromData(Data.makeFromFileName(filename))
val time1 = System.nanoTime()
println("Making codec took " + (time1 - time0) + " ns")
val time2 = System.nanoTime()
val pixels = codec.readPixels()
val time3 = System.nanoTime()
println("Reading ${pixels.width}x${pixels.height} pixels took " + (time3 - time2) + " ns")
val imageInfo = ImageInfo(
width = codec.width / 8, height = codec.height / 8,
colorType = codec.colorType,
alphaType = codec.alphaType
)
val bitmap = Bitmap()
bitmap.setImageInfo(imageInfo)
bitmap.allocPixels()
val time4 = System.nanoTime()
val pixelsSmall = codec.readPixels(bitmap)
val time5 = System.nanoTime()
println("Reading ${bitmap.width}x${bitmap.height} pixels took " + (time5 - time4) + " ns")
Kirill Grouchnikov
01/29/2024, 2:06 PMMaking codec took 266628708 ns
Reading 2560x1150 pixels took 115026375 ns
Reading 320x143 pixels took 86284709 ns
Stefan Oltmann
01/29/2024, 2:06 PMKirill Grouchnikov
01/29/2024, 2:07 PMStefan Oltmann
01/29/2024, 2:08 PMKirill Grouchnikov
01/29/2024, 2:08 PMkInvalidScale
Stefan Oltmann
01/29/2024, 2:08 PMKirill Grouchnikov
01/29/2024, 2:09 PMStefan Oltmann
01/29/2024, 2:10 PMKirill Grouchnikov
01/29/2024, 2:10 PMStefan Oltmann
01/30/2024, 5:39 AMStefan Oltmann
01/30/2024, 6:03 AMkInvalidScale
Some of my test images even don't work with that.
There seem to be some (undocumented?) restrictions to this. It's a bit of magic.
Hopefully someone on the mailing list can explain the rules.
Thanks for your code snippet. I learned something new about SKIA today. 🙂Stefan Oltmann
01/30/2024, 1:39 PMKirill Grouchnikov
01/30/2024, 2:04 PMStefan Oltmann
01/30/2024, 2:06 PMsaket
01/30/2024, 2:48 PMsaket
01/30/2024, 2:49 PMKirill Grouchnikov
01/30/2024, 2:52 PMsaket
01/30/2024, 2:54 PMStefan Oltmann
02/02/2024, 7:12 AMStefan Oltmann
02/02/2024, 7:32 AMStefan Oltmann
02/02/2024, 7:43 AMjpeg_calc_output_dimensions()
to calculate the correct dimensions.
Seems to involve quite some magic to determine that.Kirill Grouchnikov
02/02/2024, 5:59 PMKirill Grouchnikov
02/02/2024, 6:00 PMStefan Oltmann
02/02/2024, 6:00 PMKirill Grouchnikov
02/02/2024, 6:01 PMKirill Grouchnikov
02/02/2024, 6:02 PMKirill Grouchnikov
02/02/2024, 6:03 PMStefan Oltmann
02/02/2024, 6:05 PM