/// <summary>
    /// Converts the .gf pixel data to raw bitmap data of a specified size
    /// </summary>
    /// <param name="gf">The GF file data</param>
    /// <param name="width">The image width</param>
    /// <param name="height">The image height</param>
    /// <param name="offset">The offset in the pixel array</param>
    /// <returns>The raw image data</returns>
    public static RawBitmapData GetRawBitmapData(this GF gf, int width, int height, int offset = 0)
    {
        // Check if the size is scaled
        bool isScaled = gf.Width != width || gf.Height != height;

        // Get the scale factors
        double widthScale  = gf.Width / (double)width;
        double heightScale = gf.Height / (double)height;

        // Get the format
        GF_Format format = gf.PixelFormat;

        // Get the pixel format
        PixelFormat pixelFormat = format.SupportsTransparency() ? PixelFormat.Format32bppArgb : PixelFormat.Format24bppRgb;

        // Get the number of bitmap channels
        int bmpChannels = Image.GetPixelFormatSize(pixelFormat) / 8;

        // Create the pixel array
        byte[] rawPixelData = new byte[width * height * bmpChannels];

        // Enumerate each pixel
        for (uint y = 0; y < height; y++)
        {
            for (uint x = 0; x < width; x++)
            {
                // Get the offsets for the pixel colors
                var pixelOffset = isScaled
                ? (long)((gf.Width * Math.Floor((y * heightScale)) + Math.Floor((x * widthScale))) * gf.Channels + offset)
                : (width * y + x) * gf.Channels + offset;

                // NOTE: We reverse the Y-axis here since the .gf images are always flipped vertically
                long rawOffset = (width * (height - y - 1) + x) * bmpChannels;

                // Get the pixels
                foreach (var b in gf.GetBGRAPixel(format, gf.PixelData, pixelOffset))
                {
                    rawPixelData[rawOffset] = b;
                    rawOffset++;
                }
            }
        }

        // Return the raw bitmap data
        return(new RawBitmapData(width, height, rawPixelData, pixelFormat));
    }