<commit_before>#include "androidimageprovider.h"

AndroidImageProvider::AndroidImageProvider()
: QQuickImageProvider(QQmlImageProviderBase::Image)
{
    Java env;
    jclass clazz = env.findClass("de/hsaugsburg/informatik/mplane/ImageHelper");
    m_instance = env.createInstance(clazz);
    m_loadApplicationIcon = env->GetMethodID(clazz, "loadApplicationIcon", "(Ljava/lang/String;)Landroid/graphics/Bitmap;");

    jclass bitmapClass = env.findClass("android/graphics/Bitmap");
    m_getWidth = env->GetMethodID(bitmapClass, "getWidth", "()I");
    m_getHeight = env->GetMethodID(bitmapClass, "getHeight", "()I");
    m_getPixels = env->GetMethodID(bitmapClass, "getPixels", "([IIIIIII)V");
}

AndroidImageProvider::~AndroidImageProvider()
{
    Java env;
    env->DeleteGlobalRef(m_instance);
}

QImage AndroidImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
    Q_UNUSED(size);
    Q_UNUSED(requestedSize);

    Java env;

    jstring packageName = env->NewString((const jchar*)id.constData(), id.length());
    jobject bm = env->CallObjectMethod(m_instance, m_loadApplicationIcon, packageName);
    env->DeleteLocalRef(packageName);

    if (bm == NULL)
        return QImage();

    jint width = env->CallIntMethod(bm, m_getWidth);
    jint height = env->CallIntMethod(bm, m_getHeight);

    jintArray pixels = env->NewIntArray(width * height);
    env->CallVoidMethod(bm, m_getPixels, pixels, 0, width, 0, 0, width, height);

    jint* realPixels = env->GetIntArrayElements(pixels, NULL);

    CleanupInfo* cleanupInfo = new CleanupInfo;
    cleanupInfo->pixels = (jintArray)env->NewGlobalRef(pixels);
    cleanupInfo->realPixels = realPixels;<commit_msg>Fill the size parameter if given.<commit_after>#include "androidimageprovider.h"

AndroidImageProvider::AndroidImageProvider()
: QQuickImageProvider(QQmlImageProviderBase::Image)
{
    Java env;
    jclass clazz = env.findClass("de/hsaugsburg/informatik/mplane/ImageHelper");
    m_instance = env.createInstance(clazz);
    m_loadApplicationIcon = env->GetMethodID(clazz, "loadApplicationIcon", "(Ljava/lang/String;)Landroid/graphics/Bitmap;");

    jclass bitmapClass = env.findClass("android/graphics/Bitmap");
    m_getWidth = env->GetMethodID(bitmapClass, "getWidth", "()I");
    m_getHeight = env->GetMethodID(bitmapClass, "getHeight", "()I");
    m_getPixels = env->GetMethodID(bitmapClass, "getPixels", "([IIIIIII)V");
}

AndroidImageProvider::~AndroidImageProvider()
{
    Java env;
    env->DeleteGlobalRef(m_instance);
}

QImage AndroidImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
    Q_UNUSED(requestedSize);

    Java env;

    jstring packageName = env->NewString((const jchar*)id.constData(), id.length());
    jobject bm = env->CallObjectMethod(m_instance, m_loadApplicationIcon, packageName);
    env->DeleteLocalRef(packageName);

    if (bm == NULL)
        return QImage();

    jint width = env->CallIntMethod(bm, m_getWidth);
    jint height = env->CallIntMethod(bm, m_getHeight);

    if (size)
        *size = QSize(width, height);

    jintArray pixels = env->NewIntArray(width * height);
    env->CallVoidMethod(bm, m_getPixels, pixels, 0, width, 0, 0, width, height);

    jint* realPixels = env->GetIntArrayElements(pixels, NULL);

    CleanupInfo* cleanupInfo = new CleanupInfo;
    cleanupInfo->pixels = (jintArray)env->NewGlobalRef(pixels);
    cleanupInfo->realPixels = realPixels;
{'fraction_non_alphanumeric': 0.13579890205143022, 'fraction_numerical': 0.0017336030049118752, 'mean_word_length': 5.171122994652406, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4314835', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1115, 'n_words': 200}