<commit_before>﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using static AssetStudio.Studio;

namespace AssetStudio
{
    static class SpriteHelper
    {
        public static Bitmap GetImageFromSprite(AssetPreloadData asset)
        {
            var m_Sprite = new Sprite(asset, true);
            if (assetsfileList.TryGetPD(m_Sprite.m_SpriteAtlas, out var assetPreloadData))
            {
                var m_SpriteAtlas = new SpriteAtlas(assetPreloadData);
                var index = m_SpriteAtlas.guids.FindIndex(x => x == m_Sprite.first);
                if (index >= 0 && assetsfileList.TryGetPD(m_SpriteAtlas.textures[index], out assetPreloadData))
                {
                    return CutImage(asset, assetPreloadData, m_SpriteAtlas.textureRects[index], m_Sprite);
                }
            }
            else<commit_msg>Fixed #217<commit_after>﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using static AssetStudio.Studio;

namespace AssetStudio
{
    static class SpriteHelper
    {
        public static Bitmap GetImageFromSprite(AssetPreloadData asset)
        {
            var m_Sprite = new Sprite(asset, true);
            if (assetsfileList.TryGetPD(m_Sprite.m_SpriteAtlas, out var assetPreloadData))
            {
                var m_SpriteAtlas = new SpriteAtlas(assetPreloadData);
                var index = m_SpriteAtlas.guids.FindIndex(x => x == m_Sprite.first);
                if (index >= 0 && assetsfileList.TryGetPD(m_SpriteAtlas.textures[index], out assetPreloadData))
                {
                    try
                    {
                        return CutImage(asset, assetPreloadData, m_SpriteAtlas.textureRects[index], m_Sprite);
                    }
                    catch
                    {
                        return CutImage(asset, assetPreloadData, m_SpriteAtlas.textureRects[index]);
                    }
                }
            }
            else
{'fraction_non_alphanumeric': 0.07921245421245421, 'fraction_numerical': 0.003205128205128205, 'mean_word_length': 2.081805359661495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1998433', 'n_tokens_mistral': 619, 'n_tokens_neox': 606, 'n_words': 122}