Programowanie w systemie UNIX/C: Różnice pomiędzy wersjami
Usunięta treść Dodana treść
m →Grafika: sudo apt-get install libgd-dev |
|||
Linia 97:
## [https://github.com/webview/webview webview]
## [https://github.com/raysan5/raygui raygui] A simple and easy-to-use immediate-mode gui library
Wczytywanie obrazu z użyciem [https://github.com/nothings/stb stb_image]<ref>[https://stackoverflow.com/questions/2076475/reading-an-image-file-in-c-c stackoverflow question: reading-an-image-file-in-c]</ref>
<syntaxhighlight lang= c>
#include <stdint.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
int main() {
int width, height, bpp;
uint8_t* rgb_image = stbi_load("image.png", &width, &height, &bpp, 3);
stbi_image_free(rgb_image);
return 0;
}
</syntaxhighlight>
Tworzenie obrazu z użyciem stb_image
<syntaxhighlight lang= c>
#include <stdint.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#define CHANNEL_NUM 3
int main() {
int width = 800;
int height = 800;
uint8_t* rgb_image;
rgb_image = malloc(width*height*CHANNEL_NUM);
// Write your code to populate rgb_image here
stbi_write_png("image.png", width, height, CHANNEL_NUM, rgb_image, width*CHANNEL_NUM);
return 0;
}
</syntaxhighlight>
==dźwięk==
|