Создание изображения из текста и накладывание одного изображения на другое.
This commit is contained in:
parent
9af7778b77
commit
38655e9c1b
5 changed files with 69 additions and 27 deletions
33
main.cpp
33
main.cpp
|
@ -4,6 +4,7 @@
|
|||
|
||||
const std::string FILENAME = "../elef.bmp";
|
||||
const std::string FILENAME_OUT = "../elef_out.bmp";
|
||||
auto font = readPSF("../fonts/ruscii_8x16_2.psf");
|
||||
|
||||
//
|
||||
void lab01() {
|
||||
|
@ -16,12 +17,18 @@ void lab01() {
|
|||
pixels2(i, j) = pixels2(i, j) * 2;
|
||||
}
|
||||
}
|
||||
auto darkenImg = BMPImage(pixels1);
|
||||
auto lighterImg = BMPImage(pixels2);
|
||||
auto invert_img = invertColors(og_image); // TODO
|
||||
auto grayscale_img = grayscale(og_image);
|
||||
og_image.appendRight(lighterImg).appendRight(darkenImg).appendRight(invert_img).appendRight(grayscale_img).save(
|
||||
"../lab01/elef1.bmp");
|
||||
auto orig_text = textImg(u"Оригинал", &font, 3);
|
||||
auto darken_text = textImg(u"Темнее", &font, 3);
|
||||
auto lighter_text = textImg(u"Светлее", &font, 3);
|
||||
auto invert_text = textImg(u"Инвертирован", &font, 3);
|
||||
auto grayscale_text = textImg(u"Оттенки серого", &font, 3);
|
||||
auto darkenImg = BMPImage(pixels1).overlay(darken_text, 0, 0);
|
||||
auto lighterImg = BMPImage(pixels2).overlay(lighter_text, 0, 0);
|
||||
auto invert_img = invertColors(og_image).overlay(invert_text, 0, 0); // TODO
|
||||
auto grayscale_img = grayscale(og_image).overlay(grayscale_text, 0, 0);
|
||||
|
||||
og_image.appendRight(lighterImg).appendRight(darkenImg).appendRight(invert_img).appendRight(grayscale_img).overlay(
|
||||
orig_text, 0, 0).save("../lab01/elef1.bmp");
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -123,13 +130,12 @@ void test() {
|
|||
void test2() {
|
||||
auto background_color = Pixel{0, 0, 0};
|
||||
auto font_color = Pixel{255, 255, 255};
|
||||
auto font = readPSF("../fonts/ruscii_8x16_2.psf");
|
||||
auto glyph = font._glyphs[u'б'];
|
||||
auto w = glyph.width;
|
||||
auto h = glyph.height;
|
||||
|
||||
int imgWidth = 16 * glyph.width;
|
||||
int imgHeight = 16 * glyph.height;
|
||||
uint32_t imgWidth = 16 * glyph.width;
|
||||
uint32_t imgHeight = 16 * glyph.height;
|
||||
PixelArray test(imgWidth, imgHeight);
|
||||
std::u16string str = u"Hello, World! Привет, Мир!";
|
||||
uint32_t k = 0;
|
||||
|
@ -151,12 +157,17 @@ void test2() {
|
|||
BMPImage(test).save("test_font.bmp");
|
||||
}
|
||||
|
||||
void test3() {
|
||||
textImg(u"Привет, Мир!", &font).save("../font_test.bmp");
|
||||
}
|
||||
|
||||
int main() {
|
||||
// lab01();
|
||||
lab01();
|
||||
// lab02_01();
|
||||
// lab02_02();
|
||||
// lab02_03();
|
||||
// test();
|
||||
test2();
|
||||
// test2();
|
||||
// test3();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue