Dahie / DDS-Utils

Java utilities for cross-platform DirectDrawSurface texture management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

what exactly means Databuffer has not the expected length?

HopingCoding opened this issue · comments

it occurs in

java.lang.IllegalStateException: Databuffer has not the expected length: 160000 instead of 640000
at ddsutil.ByteBufferedImage.convertDataBufferToARGBArray(ByteBufferedImage.java:139)
at ddsutil.ByteBufferedImage.convertBIintoARGBArray(ByteBufferedImage.java:111)
at compression.DXTBufferCompressor.(DXTBufferCompressor.java:66)

is this because my input image is bad (it's a png) ?

on the other hand, when i use Dropps to convert that exact png it works!

I'm missing a bit of context, let me see if I'm right on the issue.

You have your BufferedImage of your PNG and you want to convert it using the "static" manual way of converting and compressing the buffers.
There is a second way employed by Dropps in creating high-level objects for the conversion. For this see DDSUtils.java:222
TextureMap is a Wrapper for the conversion, taking the BufferedImage and dealing with the conversions.

Anyway, I don't think this is your problem. The issue is more likely this: BufferedImage has different Types describing how colors are encoded in the Databuffer. So there are different bit-ranges and bit-orders. My supported is rather limited to ARGB, on the DataBuffer-end (see ByteBufferedImage.java:126 ). What I do in Dropps is to take any BufferedImage and reconvert it into ARGB ( see DDSUtils.java:231 ). This could solve your problem, if you don't mind the extra conversion step.