This pull request introduces several improvements to the oslLoadImageFileJPG function to enhance its robustness, readability, and overall performance. The changes include:
Added Null Checks: The function now verifies that filename is not NULL before proceeding with file operations, preventing potential crashes.
Pixel Format Validation: Early exit if the pixel format is not suitable (i.e., not true color), saving processing time and resources.
Improved Resource Management: Ensured proper cleanup of resources, including memory and file handles, even if errors occur during processing.
Enhanced Error Handling: Added more robust error handling to manage scenarios where file reading or memory allocation fails, ensuring graceful failure.
Alpha Channel Handling: Explicitly included the alpha channel (0xFF) when setting pixel data, improving image accuracy.
Adjusted Scanline Index: Corrected the pixel-setting logic to use the proper scanline index, ensuring accurate image rendering.
Code Readability: Improved the code's structure and added comments for better readability and maintainability.
This pull request introduces several improvements to the
oslLoadImageFileJPG
function to enhance its robustness, readability, and overall performance. The changes include:Added Null Checks: The function now verifies that
filename
is notNULL
before proceeding with file operations, preventing potential crashes.Pixel Format Validation: Early exit if the pixel format is not suitable (i.e., not true color), saving processing time and resources.
Improved Resource Management: Ensured proper cleanup of resources, including memory and file handles, even if errors occur during processing.
Enhanced Error Handling: Added more robust error handling to manage scenarios where file reading or memory allocation fails, ensuring graceful failure.
Alpha Channel Handling: Explicitly included the alpha channel (0xFF) when setting pixel data, improving image accuracy.
Adjusted Scanline Index: Corrected the pixel-setting logic to use the proper scanline index, ensuring accurate image rendering.
Code Readability: Improved the code's structure and added comments for better readability and maintainability.