summaryrefslogtreecommitdiff
path: root/core/fxge/dib/fx_dib_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge/dib/fx_dib_main.cpp')
-rw-r--r--core/fxge/dib/fx_dib_main.cpp85
1 files changed, 1 insertions, 84 deletions
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index ad6ee0c4e7..85df71e11d 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -1371,90 +1371,7 @@ FX_BOOL CFX_DIBitmap::ConvertColorScale(uint32_t forecolor,
}
return TRUE;
}
-FX_BOOL CFX_DIBitmap::DitherFS(const uint32_t* pPalette,
- int pal_size,
- const FX_RECT* pRect) {
- if (!m_pBuffer) {
- return FALSE;
- }
- if (m_bpp != 8 && m_pPalette && m_AlphaFlag != 0) {
- return FALSE;
- }
- if (m_Width < 4 && m_Height < 4) {
- return FALSE;
- }
- FX_RECT rect(0, 0, m_Width, m_Height);
- if (pRect) {
- rect.Intersect(*pRect);
- }
- uint8_t translate[256];
- for (int i = 0; i < 256; i++) {
- int err2 = 65536;
- for (int j = 0; j < pal_size; j++) {
- uint8_t entry = (uint8_t)pPalette[j];
- int err = (int)entry - i;
- if (err * err < err2) {
- err2 = err * err;
- translate[i] = entry;
- }
- }
- }
- for (int row = rect.top; row < rect.bottom; row++) {
- uint8_t* scan = m_pBuffer + row * m_Pitch;
- uint8_t* next_scan = m_pBuffer + (row + 1) * m_Pitch;
- for (int col = rect.left; col < rect.right; col++) {
- int src_pixel = scan[col];
- int dest_pixel = translate[src_pixel];
- scan[col] = (uint8_t)dest_pixel;
- int error = -dest_pixel + src_pixel;
- if (col < rect.right - 1) {
- int src = scan[col + 1];
- src += error * 7 / 16;
- if (src > 255) {
- scan[col + 1] = 255;
- } else if (src < 0) {
- scan[col + 1] = 0;
- } else {
- scan[col + 1] = src;
- }
- }
- if (col < rect.right - 1 && row < rect.bottom - 1) {
- int src = next_scan[col + 1];
- src += error * 1 / 16;
- if (src > 255) {
- next_scan[col + 1] = 255;
- } else if (src < 0) {
- next_scan[col + 1] = 0;
- } else {
- next_scan[col + 1] = src;
- }
- }
- if (row < rect.bottom - 1) {
- int src = next_scan[col];
- src += error * 5 / 16;
- if (src > 255) {
- next_scan[col] = 255;
- } else if (src < 0) {
- next_scan[col] = 0;
- } else {
- next_scan[col] = src;
- }
- }
- if (col > rect.left && row < rect.bottom - 1) {
- int src = next_scan[col - 1];
- src += error * 3 / 16;
- if (src > 255) {
- next_scan[col - 1] = 255;
- } else if (src < 0) {
- next_scan[col - 1] = 0;
- } else {
- next_scan[col - 1] = src;
- }
- }
- }
- }
- return TRUE;
-}
+
CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const {
CFX_DIBitmap* pFlipped = new CFX_DIBitmap;
if (!pFlipped->Create(m_Width, m_Height, GetFormat())) {