You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/AtomLyIntegration/AtomFont/Code/Platform/Windows/FontTexture_Windows.cpp

68 lines
2.1 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AtomLyIntegration/AtomFont/AtomFont_precompiled.h>
#if !defined(USE_NULLFONT_ALWAYS)
#include <AtomLyIntegration/AtomFont/FontTexture.h>
//-------------------------------------------------------------------------------------------------
int AZ::FontTexture::WriteToFile(const string& fileName)
{
AZ::IO::FileIOStream outputFile(fileName.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary);
if (!outputFile.IsOpen())
{
return 0;
}
BITMAPFILEHEADER pHeader;
BITMAPINFOHEADER pInfoHeader;
memset(&pHeader, 0, sizeof(BITMAPFILEHEADER));
memset(&pInfoHeader, 0, sizeof(BITMAPINFOHEADER));
pHeader.bfType = 0x4D42;
pHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + m_width * m_height * 3;
pHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
pInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
pInfoHeader.biWidth = m_width;
pInfoHeader.biHeight = m_height;
pInfoHeader.biPlanes = 1;
pInfoHeader.biBitCount = 24;
pInfoHeader.biCompression = 0;
pInfoHeader.biSizeImage = m_width * m_height * 3;
outputFile.Write(sizeof(BITMAPFILEHEADER), &pHeader);
outputFile.Write(sizeof(BITMAPINFOHEADER), &pInfoHeader);
unsigned char cRGB[3];
for (int i = m_height - 1; i >= 0; i--)
{
for (int j = 0; j < m_width; j++)
{
cRGB[0] = m_buffer[(i * m_width) + j];
cRGB[1] = *cRGB;
cRGB[2] = *cRGB;
outputFile.Write(3, cRGB);
}
}
return 1;
}
#endif