/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#include "ImageLoaderPng.hpp"
#include "Base/Utils.hpp"
#include <Data/Containers/Array.hpp>
#include <fstream>
#include <cstring>

namespace OpenVulkano::Image
{
	std::unique_ptr<Image> ImageLoaderPng::loadFromFile(const std::string& filePath)
	{
		Array<char> buffer = OpenVulkano::Utils::ReadFile(filePath);
		return loadData(reinterpret_cast<uint8_t*>(buffer.Data()), static_cast<int>(buffer.Size()));
	}

	std::unique_ptr<Image> ImageLoaderPng::loadFromMemory(const std::vector<uint8_t>& buffer)
	{
		return loadData(buffer.data(), static_cast<int>(buffer.size()));
	}

	Math::Vector2i ImageLoaderPng::GetImageDimensions(const std::string& filename)
	{
		return GetDimensionsInternal(filename);
	}
}