Marcus Overhagen pointed out that I had no idea how memset worked, so I fixed that problem by not using memset at all and used memcpy instead
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@731 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d6b71edf06
commit
8678adcbd9
@ -1587,35 +1587,31 @@ translate_from_bmppal_to_bits(BPositionIO *inSource,
|
|||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// bmp_memset
|
// pixelcpy
|
||||||
//
|
//
|
||||||
// Copies data from setto into dest for len bytes. If len <= 4,
|
// Copies count 32-bit pixels with a color value of pixel to dest.
|
||||||
// memcpy is used because memset doesn't seem to do anything if
|
|
||||||
// len is less than or equal to 4. When len > 4, memset is used
|
|
||||||
// to copy setto over and over into dest.
|
|
||||||
//
|
//
|
||||||
// Preconditions:
|
// Preconditions:
|
||||||
//
|
//
|
||||||
// Parameters: dest, where data will be written
|
// Parameters: dest, where the pixel data will be copied to
|
||||||
//
|
//
|
||||||
// setto, the data to copy to dest
|
// pixel, the 32-bit color value to copy to dest
|
||||||
|
// count times
|
||||||
//
|
//
|
||||||
// len, the amount of bytes to copy to
|
// count, the number of times pixel is copied to
|
||||||
// dest, if more than 4,
|
// dest
|
||||||
// the 4 bytes that is setto is
|
|
||||||
// copied to dest over and over
|
|
||||||
//
|
//
|
||||||
// Postconditions:
|
// Postconditions:
|
||||||
//
|
//
|
||||||
// Returns: whatever memcpy and memset return
|
// Returns:
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
void *
|
void
|
||||||
bmp_memset(void *dest, int setto, size_t len)
|
pixelcpy(uint8 *dest, uint32 pixel, uint32 count)
|
||||||
{
|
{
|
||||||
if (len <= 4)
|
for (uint32 i = 0; i < count; i++) {
|
||||||
return memcpy(dest, &setto, len);
|
memcpy(dest, &pixel, 4);
|
||||||
else
|
dest += 4;
|
||||||
return memset(dest, setto, len);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
@ -1716,8 +1712,8 @@ translate_from_bmppalr_to_bits(BPositionIO *inSource,
|
|||||||
// if there are columns remaing on this
|
// if there are columns remaing on this
|
||||||
// line, set them to the color at index zero
|
// line, set them to the color at index zero
|
||||||
if (bmppixcol < msheader.width)
|
if (bmppixcol < msheader.width)
|
||||||
bmp_memset(bitsRowData + (bmppixcol * 4), defaultcolor,
|
pixelcpy(bitsRowData + (bmppixcol * 4),
|
||||||
(msheader.width - bmppixcol) * 4);
|
defaultcolor, msheader.width - bmppixcol);
|
||||||
outDestination->Write(bitsRowData, bitsRowBytes);
|
outDestination->Write(bitsRowData, bitsRowBytes);
|
||||||
bmppixcol = 0;
|
bmppixcol = 0;
|
||||||
bmppixrow++;
|
bmppixrow++;
|
||||||
@ -1738,8 +1734,8 @@ translate_from_bmppalr_to_bits(BPositionIO *inSource,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (bmppixrow < msheader.height) {
|
while (bmppixrow < msheader.height) {
|
||||||
bmp_memset(bitsRowData + (bmppixcol * 4), defaultcolor,
|
pixelcpy(bitsRowData + (bmppixcol * 4), defaultcolor,
|
||||||
(msheader.width - bmppixcol) * 4);
|
msheader.width - bmppixcol);
|
||||||
outDestination->Write(bitsRowData, bitsRowBytes);
|
outDestination->Write(bitsRowData, bitsRowBytes);
|
||||||
bmppixcol = 0;
|
bmppixcol = 0;
|
||||||
bmppixrow++;
|
bmppixrow++;
|
||||||
@ -1776,8 +1772,8 @@ translate_from_bmppalr_to_bits(BPositionIO *inSource,
|
|||||||
// set all pixels to the first entry in
|
// set all pixels to the first entry in
|
||||||
// the palette, for the number of rows skipped
|
// the palette, for the number of rows skipped
|
||||||
while (dy > 0) {
|
while (dy > 0) {
|
||||||
bmp_memset(bitsRowData + (bmppixcol * 4), defaultcolor,
|
pixelcpy(bitsRowData + (bmppixcol * 4), defaultcolor,
|
||||||
(msheader.width - bmppixcol) * 4);
|
msheader.width - bmppixcol);
|
||||||
outDestination->Write(bitsRowData, bitsRowBytes);
|
outDestination->Write(bitsRowData, bitsRowBytes);
|
||||||
bmppixcol = 0;
|
bmppixcol = 0;
|
||||||
bmppixrow++;
|
bmppixrow++;
|
||||||
@ -1786,8 +1782,8 @@ translate_from_bmppalr_to_bits(BPositionIO *inSource,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bmppixcol < (uint32) lastcol + dx) {
|
if (bmppixcol < (uint32) lastcol + dx) {
|
||||||
bmp_memset(bitsRowData + (bmppixcol * 4), defaultcolor,
|
pixelcpy(bitsRowData + (bmppixcol * 4), defaultcolor,
|
||||||
(dx + lastcol - bmppixcol) * 4);
|
dx + lastcol - bmppixcol);
|
||||||
bmppixcol = dx + lastcol;
|
bmppixcol = dx + lastcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user