Initial commit

This commit is contained in:
2025-11-01 23:54:33 -05:00
commit f397068f8d
44 changed files with 13027 additions and 0 deletions

46
examples/capture.cpp Normal file
View File

@@ -0,0 +1,46 @@
#include "TessesFrameworkGFX/TessesFrameworkGFX.hpp"
#include <cstdlib>
using namespace Tesses::Framework;
using namespace Tesses::Framework::Graphics;
using namespace Tesses::Framework::Graphics::ImageFormats;
using namespace Tesses::Framework::Streams;
int main(int argc, char** argv)
{
Tesses::Framework::TF_Init();
auto devs = Device::GetDevices();
for(auto dev : devs)
{
for(auto res : dev.Resolutions)
{
Device dev2(dev.Device, res,10);
dev2.Open();
usleep(5000000);
auto frame = dev2.ReadFrame();
if(frame != nullptr)
{
Image clock;
Image clock2;
auto strm = std::make_shared<FileStream>("capture.png","wb");
auto date = Tesses::Framework::Date::DateTime::Now();
auto dateStr = date.ToString("%Y/%m/%d %I:%M %p");
clock.SetSize(GetCharWidth(dateStr.size()),CharHeight+2, Color(0,0,0,0));
//frame->FillRectangle(Rectangle(0,0,w,CharHeight+2),Colors::Blue);
clock.DrawString(dateStr,Point(0,1),Colors::Black);
clock.Resize(&clock2,Size(clock.Width()*2,clock.Height()*2));
frame->DrawImage(&clock2,Point(0,0), ImageCopyEffect::InvertIfNotTransparent);
Formats::Png.Save(strm,frame.get());
}
dev2.Close();
break;
}
}
return 0;
}

72
examples/createbmp.cpp Normal file
View File

@@ -0,0 +1,72 @@
#include "TessesFrameworkGFX/TessesFrameworkGFX.hpp"
#include <cstdlib>
using namespace Tesses::Framework;
using namespace Tesses::Framework::Graphics;
using namespace Tesses::Framework::Graphics::ImageFormats;
using namespace Tesses::Framework::Streams;
#define WIDTH 19
#define HEIGHT 12
#define A 0x0A
#define B 0x0B
#define C 0x0C
char house[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //1
0,0,0,0,0,0,0,0,9,9,0,0,0,7,0,0,B,B,0, //2
0,0,0,8,8,0,0,0,9,9,0,0,7,6,7,0,A,0,B, //3
0,0,0,8,8,0,0,0,0,0,0,7,C,C,C,7,A,0,0, //4
0,8,8,8,8,8,8,0,0,0,7,C,C,C,C,C,7,0,0, //5
0,8,8,8,8,8,8,0,0,7,7,7,7,7,7,7,7,7,0, //6
0,0,0,8,8,0,0,0,0,1,5,5,5,5,5,5,5,1,0, //7
0,0,0,8,8,0,0,0,0,1,6,5,3,3,3,5,6,1,0, //8
4,4,4,8,8,4,4,4,4,1,6,5,3,2,3,5,6,1,4, //9
4,4,4,8,8,4,4,4,4,1,5,5,3,2,3,5,5,1,4, //10
4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,4, //11
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 //12
};
int main(int argc, char** argv)
{
TF_InitWithConsole();
Color pallete[] = {
Colors::SkyBlue,
Colors::Grey,
Colors::Crimson,
Colors::Lime,
Colors::LawnGreen,
Colors::DarkOliveGreen,
Colors::DimGrey,
Colors::BurlyWood,
Colors::White,
Colors::Yellow,
Colors::FireBrick,
Colors::WhiteSmoke,
Colors::DarkGoldenRod
};
Image img(WIDTH*32,HEIGHT*32);
for(uint32_t y = 0; y < HEIGHT; y++)
{
for(uint32_t x = 0; x < WIDTH; x++)
{
char c = house[y * WIDTH + x];
for(uint32_t y0 = 0; y0 < 32; y0++)
{
uint32_t y1 = y * 32 + y0;
for(uint32_t x0 = 0; x0 < 32;x0++)
{
uint32_t x1 = x * 32 + x0;
img.SetPixel(x1,y1, pallete[c]);
}
}
}
}
auto strm = std::make_shared<FileStream>("house.bmp","wb");
Formats::Bitmap.Save(strm,&img);
}

38
examples/drawfont.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include "TessesFrameworkGFX/TessesFrameworkGFX.hpp"
#include <cstdlib>
using namespace Tesses::Framework;
using namespace Tesses::Framework::Graphics;
using namespace Tesses::Framework::Graphics::ImageFormats;
using namespace Tesses::Framework::Streams;
int main(int argc, char** argv)
{
TF_InitWithConsole();
Image img;
auto strm = std::make_shared<FileStream>(argv[1],"wb");
std::vector<std::string> chrs = {
"!\"#$%&\'(",
")*+,-./0",
"12345678",
"9:;<=>?@",
"ABCDEFGH",
"IJKLMNOP",
"QRSTUVWX",
"YZ[\\]^_`",
"{|}~TGFX"
};
img.SetSize(144,(uint32_t)(18*chrs.size()),Colors::White);
for(int y = 0; y < chrs.size(); y++)
{
for(int x = 0; x < 8; x++)
{
img.DrawChar(chrs[y][x],Point(1+(18*x),1+(18*y)),Colors::Black);
}
}
Formats::Png.Save(strm,&img);
}

22
examples/drawtext.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include "TessesFrameworkGFX/TessesFrameworkGFX.hpp"
#include <cstdlib>
using namespace Tesses::Framework;
using namespace Tesses::Framework::Graphics;
using namespace Tesses::Framework::Graphics::ImageFormats;
using namespace Tesses::Framework::Streams;
int main(int argc, char** argv)
{
TF_InitWithConsole();
Image img;
std::string text=argv[1];
auto strm = std::make_shared<FileStream>(argv[2],"wb");
img.SetSize((uint32_t)GetCharWidth(text.size()),CharHeight+2,Colors::White);
img.DrawString(text,Point(0,1),Colors::Black);
Formats::Png.Save(strm,&img);
}

23
examples/fillrect.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "TessesFrameworkGFX/TessesFrameworkGFX.hpp"
#include <cstdlib>
using namespace Tesses::Framework;
using namespace Tesses::Framework::Graphics;
using namespace Tesses::Framework::Graphics::ImageFormats;
using namespace Tesses::Framework::Streams;
int main(int argc, char** argv)
{
TF_InitWithConsole();
Image img;
img.SetSize(128,128,Color::Parse(argv[2]));
auto strm = std::make_shared<FileStream>(argv[1],"wb");
img.FillRectangle(Rectangle(32,32,64,64),Color::Parse(argv[3]));
img.DrawLine(Point(8,8),Point(100,58),Colors::Yellow,10);
img.DrawLine(Point(100,58),Point(8,100),Colors::Yellow,10);
Formats::Png.Save(strm,&img);
}

23
examples/getdevices.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "TessesFrameworkGFX/TessesFrameworkGFX.hpp"
#include <cstdlib>
using namespace Tesses::Framework;
using namespace Tesses::Framework::Graphics;
using namespace Tesses::Framework::Graphics::ImageFormats;
using namespace Tesses::Framework::Streams;
int main(int argc, char** argv)
{
auto devs = Device::GetDevices();
for(auto dev : devs)
{
std::cout << dev.Name << std::endl;
for(auto res : dev.Resolutions)
{
std::cout << "\t" << res.ToString() << std::endl;
}
std::cout << std::endl;
}
return 0;
}

19
examples/png2bmp.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "TessesFrameworkGFX/TessesFrameworkGFX.hpp"
#include <cstdlib>
using namespace Tesses::Framework;
using namespace Tesses::Framework::Graphics;
using namespace Tesses::Framework::Graphics::ImageFormats;
using namespace Tesses::Framework::Streams;
int main(int argc, char** argv)
{
TF_InitWithConsole();
Image img;
auto srcStrm = std::make_shared<FileStream>(argv[1],"rb");
auto strm = std::make_shared<FileStream>(argv[2],"wb");
Formats::Png.Load(srcStrm,&img);
Formats::Bitmap.Save(strm,&img);
}

23
examples/resize.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "TessesFrameworkGFX/TessesFrameworkGFX.hpp"
#include <cstdlib>
using namespace Tesses::Framework;
using namespace Tesses::Framework::Graphics;
using namespace Tesses::Framework::Graphics::ImageFormats;
using namespace Tesses::Framework::Streams;
int main(int argc, char** argv)
{
TF_Init();
auto srcStrm = std::make_shared<FileStream>(argv[2],"rb");
auto destStrm = std::make_shared<FileStream>(argv[3],"wb");
auto res = Http::HttpUtils::SplitString(argv[1],"x");
int w = std::stoi(res.at(0));
int h = std::stoi(res.at(1));
Image srcImg;
Image destImg;
Formats::Png.Load(srcStrm, &srcImg);
srcImg.Resize(&destImg,Size(w,h));
Formats::Png.Save(destStrm,&destImg);
}