/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "OdaCommon.h" #include "SrDataBuffer.h" OdSrDataBuffer::OdSrDataBuffer() : m_pData(nullptr), m_scanLineLength(0), m_width(0), m_height(0), m_bpp(TextureFormat::BPP24), m_colorOrder(TextureFormat::BGR), m_usePalette(false), m_transparency(TextureFormat::None), m_pTexPalette(nullptr), m_pixelGetter(nullptr), m_pixelSetter(nullptr) { // Initialize with default pixel access functions updateAccessFunctions(); } void OdSrDataBuffer::updateAccessFunctions() { // Select appropriate getter function if (m_usePalette) { switch (m_bpp) { case TextureFormat::BPP1: m_pixelGetter = m_transparency != TextureFormat::None ? &TextureGetters::Get1bppPaletteTransparent : &TextureGetters::Get1bppPalette; break; case TextureFormat::BPP4: m_pixelGetter = m_transparency != TextureFormat::None ? &TextureGetters::Get4bppPaletteTransparent : &TextureGetters::Get4bppPalette; break; case TextureFormat::BPP8: m_pixelGetter = m_transparency != TextureFormat::None ? &TextureGetters::Get8bppPaletteTransparent : &TextureGetters::Get8bppPalette; break; default: m_pixelGetter = nullptr; m_pixelSetter = nullptr; break; } } else { // Direct color formats switch (m_bpp) { case TextureFormat::BPP24: m_pixelGetter = m_colorOrder == TextureFormat::RGB ? &TextureGetters::Get24bppRGB : &TextureGetters::Get24bppBGR; m_pixelSetter = m_colorOrder == TextureFormat::RGB ? &TextureSetters::Set24bppRGB : &TextureSetters::Set24bppBGR; break; case TextureFormat::BPP32: if (m_colorOrder == TextureFormat::RGB) { switch (m_transparency) { case TextureFormat::None: m_pixelGetter = &TextureGetters::Get32bppRGB; m_pixelSetter = &TextureSetters::Set32bppRGB; break; case TextureFormat::OneBit: m_pixelGetter = &TextureGetters::Get32bppRGB_Transparent1Bit; m_pixelSetter = &TextureSetters::Set32bppRGB_Transparent1Bit; break; case TextureFormat::EightBit: m_pixelGetter = &TextureGetters::Get32bppRGB_Transparent8Bit; m_pixelSetter = &TextureSetters::Set32bppRGB_Transparent8Bit; break; default: m_pixelGetter = nullptr; m_pixelSetter = nullptr; break; } } else { switch (m_transparency) { case TextureFormat::None: m_pixelGetter = &TextureGetters::Get32bppBGR; m_pixelSetter = &TextureSetters::Set32bppBGR; break; case TextureFormat::Default: m_pixelGetter = &TextureGetters::Get32bppBGR; m_pixelSetter = &TextureSetters::Set32bppBGR; break; case TextureFormat::OneBit: m_pixelGetter = &TextureGetters::Get32bppBGR_Transparent1Bit; m_pixelSetter = &TextureSetters::Set32bppBGR_Transparent1Bit; break; case TextureFormat::EightBit: m_pixelGetter = &TextureGetters::Get32bppBGR_Transparent8Bit; m_pixelSetter = &TextureSetters::Set32bppBGR_Transparent8Bit; break; default: m_pixelGetter = nullptr; m_pixelSetter = nullptr; break; } } break; default: m_pixelGetter = nullptr; m_pixelSetter = nullptr; break; } } }