Skip to content

Commit

Permalink
add pushImageARGB function ( for argb8888_t* / bgra8888_t* )
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Aug 12, 2024
1 parent 043f114 commit 42f0986
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/lgfx/v1/LGFXBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1510,15 +1510,15 @@ namespace lgfx
else
if (pc_post.dst_bits > 16) {
if (dst_depth == rgb888_3Byte) {
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<bgr888_t>;
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<bgr888_t, argb8888_t>;
} else {
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<bgr666_t>;
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<bgr666_t, argb8888_t>;
}
} else {
if (dst_depth == rgb565_2Byte) {
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<swap565_t>;
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<swap565_t, argb8888_t>;
} else { // src_depth == rgb332_1Byte:
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<rgb332_t>;
pc_post.fp_copy = pixelcopy_t::blend_rgb_fast<rgb332_t, argb8888_t>;
}
}
push_image_affine_aa(matrix, pc, &pc_post);
Expand Down
28 changes: 28 additions & 0 deletions src/lgfx/v1/LGFXBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,34 @@ namespace lgfx
LGFX_INLINE_T void pushGrayscaleImageRotateZoom(float dst_x, float dst_y, float src_x, float src_y, float angle, float zoom_x, float zoom_y, int32_t w, int32_t h, const uint8_t* image, color_depth_t depth, const T& forecolor, const T& backcolor) { push_grayimage_rotate_zoom(dst_x, dst_y, src_x, src_y, angle, zoom_x, zoom_y, w, h, image, depth, convert_to_rgb888(forecolor), convert_to_rgb888(backcolor)); }
LGFX_INLINE_T void pushGrayscaleImageAffine(const float matrix[6], int32_t w, int32_t h, const uint8_t* image, color_depth_t depth, const T& forecolor, const T& backcolor) { push_grayimage_affine(matrix, w, h, image, depth, convert_to_rgb888(forecolor), convert_to_rgb888(backcolor)); }

//----------------------------------------------------------------------------

// T == bgra8888_t or argb8888_t
template<typename T>
void pushImageARGB(int32_t x, int32_t y, int32_t w, int32_t h, const T* data)
{
auto pc = create_pc(data);
if (pc.dst_bits > 16) {
if (pc.dst_depth == rgb888_3Byte) {
pc.fp_copy = pixelcopy_t::blend_rgb_fast<bgr888_t, T>;
} else {
pc.fp_copy = pixelcopy_t::blend_rgb_fast<bgr666_t, T>;
}
} else {
if (pc.dst_depth == rgb565_2Byte) {
pc.fp_copy = pixelcopy_t::blend_rgb_fast<swap565_t, T>;
} else { // src_depth == rgb332_1Byte:
pc.fp_copy = pixelcopy_t::blend_rgb_fast<rgb332_t, T>;
}
}
pc.src_bitwidth = w;
pc.src_width = w;
pc.src_height = h;
startWrite();
_panel->writeImageARGB(x, y, w, h, &pc);
endWrite();
}

//----------------------------------------------------------------------------

/// read RGB565 16bit color
Expand Down
8 changes: 7 additions & 1 deletion src/lgfx/v1/misc/common_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ namespace lgfx

void memset_multi(uint8_t* buf, uint32_t c, size_t size, size_t length)
{
if (size == 1 || ((c & 0xFF) == ((c >> 8) & 0xFF) && (size == 2 || ((c & 0xFF) == ((c >> 16) & 0xFF)))))
if (size == 1
|| ( (c & 0xFF) == ((c >> 8) & 0xFF)
&& ( size == 2
|| ( (c & 0xFF) == ((c >> 16) & 0xFF)
&& ( size == 3
|| ( (c & 0xFF) == ((c >> 24) & 0xFF)
))))))
{
memset(buf, c, size * length);
return;
Expand Down
6 changes: 3 additions & 3 deletions src/lgfx/v1/misc/pixelcopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,21 +449,21 @@ namespace lgfx
return last;
}

template <typename TDst>
template <typename TDst, typename TSrc>
static uint32_t blend_rgb_fast(void* __restrict dst, uint32_t index, uint32_t last, pixelcopy_t* __restrict param)
{
auto d = static_cast<TDst*>(dst);
auto src_x32_add = param->src_x32_add;
auto src_y32_add = param->src_y32_add;
auto s = static_cast<const argb8888_t*>(param->src_data);
auto s = static_cast<const TSrc*>(param->src_data);
for (;;) {
uint32_t i = param->src_x + param->src_y * param->src_bitwidth;
uint_fast16_t a = s[i].a;
if (a)
{
if (a == 255)
{
d[index].set(s[i].r, s[i].g, s[i].b);
d[index].set(s[i].R8(), s[i].G8(), s[i].B8());
param->src_x32 += src_x32_add;
param->src_y32 += src_y32_add;
if (++index == last) return last;
Expand Down

0 comments on commit 42f0986

Please sign in to comment.