minor update
This commit is contained in:
@@ -62,10 +62,7 @@ struct ColorARGB {
|
|||||||
this->value = rhs.value;
|
this->value = rhs.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t toRGBA() const {
|
operator uint32_t() const {
|
||||||
// swap B/R channels
|
return this->value;
|
||||||
return (this->value & 0xff00ff00)
|
|
||||||
| ((this->value >> 16) & 0xff)
|
|
||||||
| ((this->value & 0xff) << 16);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Binary file not shown.
Binary file not shown.
@@ -20,11 +20,10 @@ void kernel_body(int task_id, void* arg) {
|
|||||||
uint32_t yoffset = task_id * _arg->tile_height;
|
uint32_t yoffset = task_id * _arg->tile_height;
|
||||||
uint8_t* dst_ptr = (uint8_t*)(_arg->karg.dst_ptr + xoffset * _arg->karg.dst_stride + yoffset * _arg->karg.dst_pitch);
|
uint8_t* dst_ptr = (uint8_t*)(_arg->karg.dst_ptr + xoffset * _arg->karg.dst_stride + yoffset * _arg->karg.dst_pitch);
|
||||||
|
|
||||||
float fu = xoffset * _arg->deltaX;
|
|
||||||
float fv = yoffset * _arg->deltaY;
|
float fv = yoffset * _arg->deltaY;
|
||||||
|
|
||||||
for (uint32_t y = 0; y < _arg->tile_height; ++y) {
|
for (uint32_t y = 0; y < _arg->tile_height; ++y) {
|
||||||
uint32_t* dst_row = (uint32_t*)dst_ptr;
|
uint32_t* dst_row = (uint32_t*)dst_ptr;
|
||||||
|
float fu = xoffset * _arg->deltaX;
|
||||||
for (uint32_t x = 0; x < _arg->tile_width; ++x) {
|
for (uint32_t x = 0; x < _arg->tile_width; ++x) {
|
||||||
int32_t u = (int32_t)(fu * (1<<20));
|
int32_t u = (int32_t)(fu * (1<<20));
|
||||||
int32_t v = (int32_t)(fv * (1<<20));
|
int32_t v = (int32_t)(fv * (1<<20));
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 16 KiB |
@@ -81,7 +81,7 @@ int LoadTGA(const char *filename,
|
|||||||
default:
|
default:
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
*dst_bytes++ = color.toRGBA();
|
*dst_bytes++ = color;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -108,6 +108,11 @@ int SaveTGA(const char *filename,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bpp < 2 || bpp > 4) {
|
||||||
|
std::cerr << "unsupported pixel stride: " << bpp << "!" << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tga_header_t header;
|
tga_header_t header;
|
||||||
header.idlength = 0;
|
header.idlength = 0;
|
||||||
header.colormaptype = 0; // no palette
|
header.colormaptype = 0; // no palette
|
||||||
@@ -131,20 +136,7 @@ int SaveTGA(const char *filename,
|
|||||||
for (uint32_t y = 0; y < height; ++y) {
|
for (uint32_t y = 0; y < height; ++y) {
|
||||||
const uint8_t* pixel_row = pixel_bytes;
|
const uint8_t* pixel_row = pixel_bytes;
|
||||||
for (uint32_t x = 0; x < width; ++x) {
|
for (uint32_t x = 0; x < width; ++x) {
|
||||||
// swap R/B color channels
|
ofs.write((const char*)pixel_row, bpp);
|
||||||
if (bpp == 4) {
|
|
||||||
ofs.write((const char*)pixel_row + 2, 1);
|
|
||||||
ofs.write((const char*)pixel_row + 1, 1);
|
|
||||||
ofs.write((const char*)pixel_row + 0, 1);
|
|
||||||
ofs.write((const char*)pixel_row + 3, 1);
|
|
||||||
} else if (bpp == 3) {
|
|
||||||
ofs.write((const char*)pixel_row + 2, 1);
|
|
||||||
ofs.write((const char*)pixel_row + 1, 1);
|
|
||||||
ofs.write((const char*)pixel_row + 0, 1);
|
|
||||||
} else{
|
|
||||||
std::cerr << "unsupported TGA bitsperpixel!" << std::endl;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
pixel_row += bpp;
|
pixel_row += bpp;
|
||||||
}
|
}
|
||||||
pixel_bytes -= pitch;
|
pixel_bytes -= pitch;
|
||||||
|
|||||||
Reference in New Issue
Block a user