Subversion Repositories tpanel

Rev

Rev 11 | Blame | Last modification | View Log | RSS feed

/*
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

#ifndef __TRESOURCES_H__
#define __TRESOURCES_H__

#include <include/core/SkImage.h>
#include <include/core/SkString.h>
#include <include/core/SkData.h>

class SkBitmap;
class SkData;
class SkStreamAsset;
class SkTypeface;

extern sk_sp<SkData> (*gResourceFactory)(const char*);

SkString GetResourcePath(const char* resource = "");

bool DecodeDataToBitmap(sk_sp<SkData> data, SkBitmap* dst);

sk_sp<SkData> GetResourceAsData(const char* resource);

inline bool GetResourceAsBitmap(const char* resource, SkBitmap* dst)
{
    return DecodeDataToBitmap(GetResourceAsData(resource), dst);
}

inline sk_sp<SkImage> GetResourceAsImage(const char* resource)
{
    return SkImage::MakeFromEncoded(GetResourceAsData(resource));
}

std::unique_ptr<SkStreamAsset> GetResourceAsStream(const char* resource);

sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource, int ttcIndex = 0);

sk_sp<SkData> readImage(const std::string& fname);

std::string toLower(std::string& str);
std::string toUpper(std::string& str);
std::vector<std::string> StrSplit(const std::string& str, const std::string& seps, const bool trimEmpty=false);
std::string UTF8ToCp1250(const std::string& str);
std::string cp1250ToUTF8(const std::string& str);
std::string latin1ToUTF8(const std::string& str);

void *renew(void *mem, size_t old_size, size_t new_size);

#endif  // __TRESOURCES_H__