1.3.49
 
Loading...
Searching...
No Matches
VisualizerCore.cpp File Reference
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <ft2build.h>
#include <FT_FREETYPE_H>
#include "Visualizer.h"

Go to the source code of this file.

Functions

int read_JPEG_file (const char *filename, std::vector< unsigned char > &texture, uint &height, uint &width)
 Reads a JPEG file and extracts its pixel data.
 
int write_JPEG_file (const char *filename, uint width, uint height, bool print_messages)
 Writes an image to a JPEG file.
 
int write_JPEG_file (const char *filename, uint width, uint height, const std::vector< helios::RGBcolor > &data, bool print_messages)
 
void read_png_file (const char *filename, std::vector< unsigned char > &texture, uint &height, uint &width)
 Reads a PNG file and extracts its pixel data.
 
bool validateTextureFile (const std::string &texture_file, bool pngonly)
 Validates the given texture file.
 

Detailed Description

Visualizer core functions including constructors, initialization, and utility functions.

Copyright (C) 2016-2025 Brian Bailey

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, version 2.

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.

Definition in file VisualizerCore.cpp.

Function Documentation

◆ read_JPEG_file()

int read_JPEG_file ( const char *  filename,
std::vector< unsigned char > &  texture,
uint height,
uint width 
)

Reads a JPEG file and extracts its pixel data.

This function reads a JPEG file from the specified path, decodes it into RGB pixel data, and populates the provided texture vector with RGBA (Red, Green, Blue, Alpha) values. Each pixel in the texture is represented as four unsigned bytes, with the alpha channel always set to 255 (opaque). The function also outputs the height and width of the image.

Parameters
[in]filenameThe path to the JPEG file to read.
[out]textureVector that will be populated with the decoded RGBA pixel data.
[out]heightReference to store the height of the read image.
[out]widthReference to store the width of the read image.
Returns
Always returns 0 upon completion.

Definition at line 30 of file VisualizerCore.cpp.

◆ read_png_file()

void read_png_file ( const char *  filename,
std::vector< unsigned char > &  texture,
uint height,
uint width 
)

Reads a PNG file and extracts its pixel data.

This function loads a PNG file and processes its pixel data into a texture format. It also retrieves the dimensions of the image.

Parameters
[in]filenamePath to the PNG file to be read.
[out]textureVector to store the extracted RGBA pixel data as unsigned char values.
[out]heightVariable to store the height (in pixels) of the loaded image.
[out]widthVariable to store the width (in pixels) of the loaded image.

Definition at line 85 of file VisualizerCore.cpp.

◆ validateTextureFile()

bool validateTextureFile ( const std::string &  texture_file,
bool  pngonly = false 
)

Validates the given texture file.

This function checks whether the provided texture file can be used for loading a texture. If the pngonly flag is set to true, the function specifically validates for PNG file formats.

Parameters
[in]texture_fileThe path to the texture file to validate.
[in]pngonly[optional] If true, only validates the file for PNG format. Defaults to false.
Returns
True if the texture file is valid, false otherwise.

Definition at line 997 of file VisualizerCore.cpp.

◆ write_JPEG_file() [1/2]

int write_JPEG_file ( const char *  filename,
uint  width,
uint  height,
bool  print_messages 
)

Writes an image to a JPEG file.

This function captures the current framebuffer content, converts it into a JPEG-compatible data structure, and writes it to the specified file.

Parameters
[in]filenameThe path to the output JPEG file.
[in]widthThe width of the image to be written.
[in]heightThe height of the image to be written.
[in]print_messages[optional] If true, outputs status messages to the console. Defaults to false.
Returns
An integer indicating success (1) or failure (0) of the writing operation.

Definition at line 47 of file VisualizerCore.cpp.

◆ write_JPEG_file() [2/2]

int write_JPEG_file ( const char *  filename,
uint  width,
uint  height,
const std::vector< helios::RGBcolor > &  data,
bool  print_messages 
)

Definition at line 76 of file VisualizerCore.cpp.