Skip to content

Question on Interleaved Bitmap / BytesPerRow wrong ? #252

@youenchene

Description

@youenchene

In bitmap.c :

if(ubFlags & BMF_INTERLEAVED) {
		pBitMap->Flags |= BMF_INTERLEAVED;
		UWORD uwRealWidth;
		uwRealWidth = pBitMap->BytesPerRow;
		pBitMap->BytesPerRow *= ubDepth;

		pBitMap->Planes[0] = (PLANEPTR) memAlloc(
			pBitMap->BytesPerRow*uwHeight,
			(ubFlags & BMF_FASTMEM) ? MEMF_ANY : MEMF_CHIP
		);
		if(!pBitMap->Planes[0]) {
			logWrite("ERR: Can't alloc interleaved bitplanes\n");
			goto fail;
		}
		for(i = 1; i != ubDepth; ++i) {
			pBitMap->Planes[i] = pBitMap->Planes[i-1] + uwRealWidth;
		}

		if (ubFlags & BMF_CLEAR) {
			memset(pBitMap->Planes[0], 0, pBitMap->Rows * pBitMap->BytesPerRow);
		}
	}

This line pBitMap->BytesPerRow *= ubDepth; bother me.

What I understood from interleaved bitmap is 1 bit is color and each bitmap is layer.

So a 32 width pixel image should be 4 bytes (so 32 bits) for one row.

And this on 4 bitplane for a 16 colors images.

According to this code the BytesPerRow become 16, so 16 bytes by row.

Did I completely losted my mind and misunderstanding interleaved or did I put my finger on a mistake in the code ?

(under the hood : I am trying to do a xflip method which drive me crazy)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo asap

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions