summaryrefslogtreecommitdiffhomepage
path: root/examples/src/textures/textures_image_processing.c
diff options
context:
space:
mode:
authorRay <[email protected]>2019-05-20 16:40:30 +0200
committerRay <[email protected]>2019-05-20 16:40:30 +0200
commit3d7d174c70b2d00fd879ade64c5085d4ff34d4aa (patch)
tree3b690948f186f855aa2ee8bab312b3ca28a56200 /examples/src/textures/textures_image_processing.c
parent0b56b996bd053ec875c229e9793f7806b666839c (diff)
downloadraylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.tar.gz
raylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.zip
Review and recompile ALL examples
Diffstat (limited to 'examples/src/textures/textures_image_processing.c')
-rw-r--r--examples/src/textures/textures_image_processing.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/examples/src/textures/textures_image_processing.c b/examples/src/textures/textures_image_processing.c
index 6d33d95..b9ed51d 100644
--- a/examples/src/textures/textures_image_processing.c
+++ b/examples/src/textures/textures_image_processing.c
@@ -13,19 +13,19 @@
#include "raylib.h"
-#include <stdlib.h> // Required for: free()
+#include <stdlib.h> // Required for: free()
#define NUM_PROCESSES 8
-typedef enum {
- NONE = 0,
- COLOR_GRAYSCALE,
- COLOR_TINT,
- COLOR_INVERT,
- COLOR_CONTRAST,
- COLOR_BRIGHTNESS,
- FLIP_VERTICAL,
- FLIP_HORIZONTAL
+typedef enum {
+ NONE = 0,
+ COLOR_GRAYSCALE,
+ COLOR_TINT,
+ COLOR_INVERT,
+ COLOR_CONTRAST,
+ COLOR_BRIGHTNESS,
+ FLIP_VERTICAL,
+ FLIP_HORIZONTAL
} ImageProcess;
static const char *processText[] = {
@@ -39,12 +39,12 @@ static const char *processText[] = {
"FLIP HORIZONTAL"
};
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
+ const int screenWidth = 800;
+ const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing");
@@ -58,9 +58,9 @@ int main()
bool textureReload = false;
Rectangle selectRecs[NUM_PROCESSES];
-
+
for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40.0f, (float)(50 + 32*i), 150.0f, 30.0f };
-
+
SetTargetFPS(60);
//---------------------------------------------------------------------------------------
@@ -81,14 +81,14 @@ int main()
if (currentProcess < 0) currentProcess = 7;
textureReload = true;
}
-
+
if (textureReload)
{
UnloadImage(image); // Unload current image data
image = LoadImage("resources/parrots.png"); // Re-load image data
- // NOTE: Image processing is a costly CPU process to be done every frame,
- // If image processing is required in a frame-basis, it should be done
+ // NOTE: Image processing is a costly CPU process to be done every frame,
+ // If image processing is required in a frame-basis, it should be done
// with a texture and by shaders
switch (currentProcess)
{
@@ -101,11 +101,11 @@ int main()
case FLIP_HORIZONTAL: ImageFlipHorizontal(&image); break;
default: break;
}
-
+
Color *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit)
UpdateTexture(texture, pixels); // Update texture with new image data
free(pixels); // Unload pixels data from RAM
-
+
textureReload = false;
}
//----------------------------------------------------------------------------------
@@ -115,9 +115,9 @@ int main()
BeginDrawing();
ClearBackground(RAYWHITE);
-
+
DrawText("IMAGE PROCESSING:", 40, 30, 10, DARKGRAY);
-
+
// Draw rectangles
for (int i = 0; i < NUM_PROCESSES; i++)
{
@@ -128,7 +128,7 @@ int main()
DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE);
DrawRectangleLines(screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, texture.width, texture.height, BLACK);
-
+
EndDrawing();
//----------------------------------------------------------------------------------
}