dest += 2;
++src;
}
destRow += destDWORDSPerRow;
}
NOTES: - I made up this code just now, and it has NOT been tested - I cannot remember in what order the pixels are within each byte of a bitplane; the code above may have to be modified to reverse the order if I got it wrong - Likewise, this code is byte endian-dependent, and so you'd have to adjust the code again if you moved to a little-endian processor.
Hans
Edited by Hans on 2012/3/26 5:45:33 Edited by Hans on 2012/3/26 5:49:39
@alfkil Definitely NOT "the fastest", but maybe "most convenient": I would considering using writePixelArray8() for easily writing bitmaps of <=256 colours & p96WritePixelArray() for bitmaps >256 colours (which can have an alpha map). These require that you have a char or long array, with each array item being the value for one pixel.
If your bitwise 01 pattern is an actual 1-bitplane mask, then you can use readPixelArray8() to quickly convert it into an array.
writePixelArray8() is a bit more hassle to use than p96WritePixelArray(), as it requires array width being rounded up, as well as a temporary rasterport bitmap.
I haven't yet got into direct manipulation of bitmaps like Hans seems to be suggesting! No doubt very fast, but probably rather convoluted if you have to handle arbitrary bitmaps.
Looks neat, but how do I get a pointer to the pixel data from a 32-bit BitMap?? I guess I can use p96WritePixelArray to write to the bitmap after converting.
@Chris My data is just a raw 1 bitplane mask with no BitMap struct or RastPort, so to use ReadPixelArray I need to set up those first. I guess initializing the BitMap structure is possible by making planes[0] point to my data, or??
My data is just a raw 1 bitplane mask with no BitMap struct or RastPort, so to use ReadPixelArray I need to set up those first. I guess initializing the BitMap structure is possible by making planes[0] point to my data, or??
yeah, planes[0] should point to your data. So you would have SOMETHING like this (untested copied+pasted+modified code):
Quote:
/*some casting or correct typing of variables will be needed for compilation, and my C is a bit rusty (I'm really thinking in E and then converting to C), and yes I didn't bother with OS4 interface stuff */
By using InitBitMap(), we avoid the need to manually work out bytesperrow & any necessary rounding/padding. Your planes[0] data MUST be written using those values.
Quote:
Looks neat, but how do I get a pointer to the pixel data from a 32-bit BitMap?? I guess I can use p96WritePixelArray to write to the bitmap after converting.
You COULD just use p96ReadPixelArray() to read your pixel data from a 32-bit bitmap into a long array, then add the alpha channel, before finally writing it back to the same (or different) bitmap using p96WritePixelArray.
If you have used readPixelArray8() to convert your mask data into a char array, then it is pretty easy to add the alpha channel to your long array of pixel data.
Looks neat, but how do I get a pointer to the pixel data from a 32-bit BitMap?? I guess I can use p96WritePixelArray to write to the bitmap after converting.
Use p96LockBitMap() to get the pointer, and the bytes-per-row. However, if the bitmap is stored in VRAM, then it will probably be faster to convert it to a temporary buffer, and use p96WritePixelArray(). This will be particularly true when p96WritePixelArray() is DMA accelerated (currently only on the Sam 440 and 460 machines).
This DMA accelerated temporary buffer thingy sounds like it could speed up AmiVNC a lot, because scanning the screen is what is by far the slowest thing right now.
Software developer for Amiga OS3 and OS4. Develops for OnyxSoft and the Amiga using E and C and occasionally C++