/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include #include #include #include #include #include #include namespace GradientSignal { void ImageAsset::Reflect(AZ::ReflectContext* context) { AZ::SerializeContext* serialize = azrtti_cast(context); if (serialize) { serialize->Class() ->Version(1, &ImageAsset::VersionConverter) ->Field("Width", &ImageAsset::m_imageWidth) ->Field("Height", &ImageAsset::m_imageHeight) ->Field("BytesPerPixel", &ImageAsset::m_bytesPerPixel) ->Field("Format", &ImageAsset::m_imageFormat) ->Field("Data", &ImageAsset::m_imageData) ; AZ::EditContext* edit = serialize->GetEditContext(); if (edit) { edit->Class( "Image Asset", "") ->DataElement(0, &ImageAsset::m_imageWidth, "Width", "Image width.") ->DataElement(0, &ImageAsset::m_imageHeight, "Height", "Image height.") ->DataElement(0, &ImageAsset::m_bytesPerPixel, "BytesPerPixel", "Image bytes per pixel.") ->DataElement(0, &ImageAsset::m_imageFormat, "Format", "Image format.") ->DataElement(0, &ImageAsset::m_imageData, "Data", "Image color data.") ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->Attribute(AZ::Edit::Attributes::ContainerCanBeModified, true) ; } } } bool ImageAsset::VersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement) { if (classElement.GetVersion() < 1) { int formatIndex = classElement.FindElement(AZ_CRC("Format", 0xdeba72df)); if (formatIndex < 0) { return false; } AZ::SerializeContext::DataElementNode& format = classElement.GetSubElement(formatIndex); if (format.Convert(context)) { format.SetData(context, ImageProcessingAtom::EPixelFormat::ePixelFormat_R8); } int bppIndex = classElement.AddElement(context, "BytesPerPixel"); AZ::SerializeContext::DataElementNode& bpp = classElement.GetSubElement(bppIndex); bpp.SetData(context, 1); } return true; } }