### Basic Installer Configuration
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/installer.txt
A simple installer configuration using RunProgram to execute 'setup.exe'.
```installer
;!@Install@!UTF-8!
Title="7-Zip 4.00"
BeginPrompt="Do you want to install the 7-Zip 4.00?"
RunProgram="setup.exe"
;!@InstallEnd@!
```
--------------------------------
### Installer Configuration with ExecuteFile and Parameters
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/installer.txt
An installer configuration that uses ExecuteFile with specific parameters for MSI installation.
```installer
;!@Install@!UTF-8!
Title="7-Zip 4.01 Update"
BeginPrompt="Do you want to install the 7-Zip 4.01 Update?"
ExecuteFile="msiexec.exe"
ExecuteParameters="/i 7zip.msi REINSTALL=ALL REINSTALLMODE=vomus"
;!@InstallEnd@!
```
--------------------------------
### Configure Installation Prefix
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/README.md
Specify a custom installation directory, such as /usr, to avoid potential issues with LD_LIBRARY_PATH.
```bash
./configure --prefix=/usr
```
--------------------------------
### Installer Configuration with ExecuteFile
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/installer.txt
An installer configuration that uses ExecuteFile to run an MSI package.
```installer
;!@Install@!UTF-8!
Title="7-Zip 4.00"
BeginPrompt="Do you want to install the 7-Zip 4.00?"
ExecuteFile="7zip.msi"
;!@InstallEnd@!
```
--------------------------------
### Creating an Installer Self-Extract Archive
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/installer.txt
Combine the SFX module, an optional configuration file, and the archive to create a self-extracting installer executable.
```bash
copy /b 7zSD.sfx + config.txt + archive.7z archive.exe
```
--------------------------------
### Build and Install Protocol Buffers
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/README.md
Standard commands to build, test, and install the C++ Protocol Buffer runtime and compiler.
```bash
$ ./configure
$ make
$ make check
$ make install
```
--------------------------------
### Install Protocol Buffers
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/python/README.txt
Install the Protocol Buffers Python package. Superuser privileges may be required.
```bash
python setup.py install
```
--------------------------------
### Install libspng Header
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/CMakeLists.txt
Installs the main libspng header file to the include directory.
```cmake
install(FILES spng/spng.h DESTINATION include)
```
--------------------------------
### Install C++ Implementation
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/python/README.txt
Install the Protocol Buffers Python package with C++ implementation support. Requires C++ protobuf runtime library.
```bash
python setup.py install --cpp_implementation
```
--------------------------------
### Build and Test Java Protocol Buffers with Maven
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/java/README.txt
Commands to build, test, and install the Protocol Buffers Java runtime library using Maven. This includes running tests and installing the library into the local Maven repository.
```bash
$ mvn test
$ mvn install
```
--------------------------------
### Build Shared libspng Library
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/CMakeLists.txt
Builds the shared version of the libspng library and installs it. Also builds an example executable if enabled.
```cmake
if(SPNG_SHARED)
add_library(spng SHARED ${spng_SOURCES})
target_link_libraries(spng ${spng_LIBS})
install(TARGETS spng DESTINATION lib)
if(BUILD_EXAMPLES)
add_executable(example examples/example.c)
target_include_directories(example PRIVATE ${PROJECT_SOURCE_DIR}/spng)
target_link_libraries(example spng ${spng_LIBS})
endif()
endif()
```
--------------------------------
### Build libspng with Meson
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/build.md
Build and install the library using Meson, specifying the release build type. Navigate to the build directory before proceeding.
```bash
meson build --buildtype=release # Default is debug
cd build
ninja
ninja install
```
--------------------------------
### Install Lite Version of Java Protocol Buffers with Maven
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/java/README.txt
Command to install the 'lite' version of the Java Protocol Buffers library using Maven with a specific profile. The resulting artifact will have the 'lite' classifier.
```bash
$ mvn install -P lite
```
--------------------------------
### Build libspng with CMake
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/build.md
Standard CMake build process to compile and install the library. Ensure optimization levels are set as needed.
```bash
mkdir cbuild
cd cbuild
cmake .. # Don't forget to set optimization level!
make
make install
```
--------------------------------
### Build Static libspng Library
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/CMakeLists.txt
Builds the static version of the libspng library and installs it.
```cmake
if(SPNG_STATIC)
add_library(spng_static STATIC ${spng_SOURCES})
target_compile_definitions(spng_static PUBLIC SPNG_STATIC)
install(TARGETS spng_static DESTINATION lib)
endif()
```
--------------------------------
### 7z Decoder Initialization and Usage Steps
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/7zC.txt
Steps to initialize and use the 7z decoder, including variable declarations and function calls for opening archives. This serves as a general guide for integrating the decoder.
```c
inStream /* implements ILookInStream interface */
CSzArEx db;
ISzAlloc allocImp;
ISzAlloc allocTempImp;
CrcGenerateTable();
SzArEx_Init(&db);
SzArEx_Open(&db, inStream, &allocMain, &allocTemp);
SzArEx_Free(&db, allocImp.Free);
```
--------------------------------
### Check Python Version
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/python/README.txt
Verify that Python 2.4 or newer is installed.
```bash
python -V
```
--------------------------------
### Configure Build Options
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/CMakeLists.txt
Sets build options for libspng, including enabling optimizations, building shared/static libraries, and building examples.
```cmake
option(ENABLE_OPT "Enable architecture-specific optimizations" ON)
option(SPNG_SHARED "Build shared lib" ON)
option(SPNG_STATIC "Build static lib" ON)
option(BUILD_EXAMPLES "Build examples" ON)
```
--------------------------------
### Configure pkg-config File
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/CMakeLists.txt
Configures the libspng.pc file for pkg-config on non-Windows systems, setting installation paths and libraries.
```cmake
if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(LIBS "-lz -lm")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/libspng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/tests/libspng.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tests/libspng.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
```
--------------------------------
### Type Name Resolution Example
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/CHANGES.txt
Illustrates a change in type name resolution where type names are no longer resolved to fields. This example shows a valid scenario that would have previously caused an error.
```protobuf
message Foo {}
message Bar {
optional int32 Foo = 1;
optional Foo baz = 2;
}
```
--------------------------------
### Compile a C++ Program with Protocol Buffers
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/README.md
Example of how to compile a C++ program that uses Protocol Buffers, including the necessary flags obtained from pkg-config.
```bash
c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
```
--------------------------------
### LZMA Decompression Example
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/lzma-sdk.txt
Decompresses an LZMA file to its original binary form.
```bash
lzma d file.lzma file.bin
```
--------------------------------
### Get Compiler and Linker Flags with pkg-config
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/README.md
Use pkg-config to retrieve the necessary compiler and linker flags for integrating Protocol Buffers into your project.
```bash
pkg-config --cflags protobuf # print compiler flags
pkg-config --libs protobuf # print linker flags
pkg-config --cflags --libs protobuf # print both
```
--------------------------------
### LZMA Compression Example
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/lzma-sdk.txt
Compresses a file using LZMA with a specified dictionary size and literal context bits. -lc0 can reduce memory requirements for decompression.
```bash
lzma e file.bin file.lzma -d16 -lc0
```
--------------------------------
### Configure Protocol Buffers for Static Linkage
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/README.md
Use this command to configure the Protocol Buffers package to install static libraries only, mitigating potential ABI compatibility issues with dynamic linking.
```bash
./configure --disable-shared
```
--------------------------------
### Get Suggested Palettes (sPLT)
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Copies suggested palettes to the provided buffer. Ensure the buffer size is adequate for the number of stored sPLT chunks. If the buffer is NULL, the number of chunks is returned.
```c
int spng_get_splt(spng_ctx *ctx, struct spng_splt *splt, uint32_t *n_splt)
```
--------------------------------
### Maven Dependency for Lite Version
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/java/README.txt
Example Maven dependency configuration to include the 'lite' version of the Protocol Buffers Java runtime library in your project.
```xml
com.google.protobuf
protobuf-java
${version}
lite
```
--------------------------------
### Build documentation with mkdocs
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/build.md
Command to build the project's documentation using mkdocs. This command should be run from the root directory of the project.
```bash
# Run in root directory
mkdocs build
```
--------------------------------
### Interpolator Types
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/game/mod_hl2mp/scripts/HudAnimations.txt
Defines how the animation progresses over its duration. Options include Linear, Accel (slow start, fast end), and Deaccel (fast start, slow end).
```script
Linear
```
```script
Accel - starts moving slow, ends fast
```
```script
Deaccel - starts moving fast, ends slow
```
--------------------------------
### Build All Projects on Linux
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/README.md
Execute this shell script in the 'src' directory to build all SDK projects and mods against the Steam Runtime on Linux.
```bash
./buildallprojects
```
--------------------------------
### Get Background Color
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the background color information for the image.
```c
int spng_get_bkgd(spng_ctx *ctx, struct spng_bkgd *bkgd)
```
--------------------------------
### File Stream Callbacks for LZMA Compression
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/lzma.txt
Sets up file input and output stream callbacks for LZMA compression using CFileSeqInStream and CFileSeqOutStream.
```C
CFileSeqInStream inStream;
CFileSeqOutStream outStream;
inStream.funcTable.Read = MyRead;
inStream.file = inFile;
outStream.funcTable.Write = MyWrite;
outStream.file = outFile;
```
--------------------------------
### Basic PNG Decoding with libspng
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/usage.md
Demonstrates the core steps for decoding a PNG image using libspng. This includes creating a context, setting the input buffer, calculating the output size for an 8-bit RGBA format, decoding the image, and freeing the context. The output format SPNG_FMT_RGBA8 ensures an 8-bit RGBA image regardless of the original PNG's format.
```c
#include
/* Create a context */
spng_ctx *ctx = spng_ctx_new(0);
/* Set an input buffer */
spng_set_png_buffer(ctx, buf, buf_size);
/* Calculate output image size */
spng_decoded_image_size(ctx, SPNG_FMT_RGBA8, &out_size);
/* Get an 8-bit RGBA image regardless of PNG format */
spng_decode_image(ctx, SPNG_FMT_RGBA8, out, out_size, 0);
/* Free context memory */
spng_ctx_free(ctx);
```
--------------------------------
### Get Image Offset
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the image offset information from the PNG context.
```c
int spng_get_offs(spng_ctx *ctx, struct spng_offs *offs)
```
--------------------------------
### Build and Test Protocol Buffers
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/python/README.txt
Build the Protocol Buffers library and run tests to ensure correct functionality on your system.
```bash
python setup.py build
python setup.py google_test
```
--------------------------------
### Protobuf Command-Line Encoding/Decoding
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/CHANGES.txt
Shows how to use the protoc compiler with --encode and --decode flags for converting between protobuf text and binary formats.
```bash
protoc --encode= --decode= ...
```
--------------------------------
### StopPanelAnimations Command
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/game/mod_hl2mp/scripts/HudAnimations.txt
Stops all active animations operating on a specified panel, starting from a specified time.
```script
StopPanelAnimations
```
--------------------------------
### Get Physical Pixel Dimensions
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the physical pixel dimensions (PPI or DPI) of the image.
```c
int spng_get_phys(spng_ctx *ctx, struct spng_phys *phys)
```
--------------------------------
### Configure libspng for Developer Builds
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/tests/README.md
Enable developer builds to expose test cases. This is a prerequisite for running unit tests.
```bash
meson configure -Ddev_build=true
```
--------------------------------
### Get Image Histogram
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the histogram information for the image. This provides a count of each color value present.
```c
int spng_get_hist(spng_ctx *ctx, struct spng_hist *hist)
```
--------------------------------
### Get Significant Bits
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the significant bits information for the image. This indicates the precision of the color channels.
```c
int spng_get_sbit(spng_ctx *ctx, struct spng_sbit *sbit)
```
--------------------------------
### Create Compressed GUI 7-Zip SFX
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/installer.txt
Commands to create a self-extracting GUI archive for 7-Zip.
```bash
7zr a g.7z 7zg.exe 7z.dll -mx
copy /b 7zS2.sfx + g.7z 7zgCompr.exe
7zgCompr.exe b -md22
```
--------------------------------
### Writing FileDescriptorProtos with protoc
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/CHANGES.txt
Illustrates using the --descriptor_set_out flag with protoc to output FileDescriptorProtos for parsed .proto files.
```bash
protoc --descriptor_set_out=output.filedescriptorlist *.proto
```
--------------------------------
### Get Row Information
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/context.md
Copies information about the current row (to be decoded or encoded) into the provided spng_row_info structure.
```c
int spng_get_row_info(spng_ctx *ctx, struct spng_row_info *row_info)
```
--------------------------------
### Profile-guided optimization with Meson
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/build.md
Steps to enable profile-guided optimization (PGO) for improved performance. This involves generating PGO data, building with it, and then rebuilding with the generated data.
```bash
# Run in root directory
git clone https://github.com/libspng/benchmark_images.git
cd build
meson configure -Dbuildtype=release --default-library both -Db_pgo=generate
ninja
./example ../benchmark_images/medium_rgb8.png
./example ../benchmark_images/medium_rgba8.png
./example ../benchmark_images/large_palette.png
Meson configure -Db_pgo=use
ninja
ninja install
```
--------------------------------
### Get Chunk Limits
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/context.md
Retrieves the current chunk size and chunk cache limits configured for the context.
```c
int spng_get_chunk_limits(spng_ctx *ctx, size_t *chunk_size, size_t *cache_limit)
```
--------------------------------
### FileSystem Configuration with Search Paths
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/game/mod_tf/gameinfo.txt
Configures the file system, including Steam App IDs and detailed search paths for game assets. This section is crucial for managing how the game loads resources from VPKs and loose files.
```text
FileSystem
{
SteamAppId 243750
SearchPaths
{
// First, mount all user customizations. This will search for VPKs and subfolders
// and mount them in alphabetical order. The easiest way to distribute a mod is to
// pack up the custom content into a VPK. To "install" a mod, just drop it in this
// folder.
//
// Note that this folder is scanned only when the game is booted.
game+mod+custom_mod mod_tf/custom/*
// Enable this if you want to load your TF custom content.
//game+mod+custom_mod |appid_440|tf/custom/*
// Now search loose files. We'll set the directory containing the gameinfo.txt file
// as the first "mod" search path (after any user customizations). This is also the one
// that's used when writing to the "mod" path.
mod+mod_write |gameinfo_path|.
game+game_write |gameinfo_path|.
vgui |gameinfo_path|.
default_write_path |gameinfo_path|.
gamebin |gameinfo_path|bin
// We search VPK files before ordinary folders, because most files will be found in
// VPK and we can avoid making thousands of file system calls to attempt to open files
// in folders where they don't exist. (Searching a VPK is much faster than making an operating
// system call.)
game_lv |appid_440|tf/tf2_lv.vpk
game+mod |appid_440|tf/tf2_textures.vpk
game+mod |appid_440|tf/tf2_sound_vo_english.vpk
game+mod |appid_440|tf/tf2_sound_misc.vpk
game+mod+vgui |appid_440|tf/tf2_misc.vpk
game |appid_243750|hl2/hl2_textures.vpk
game |appid_243750|hl2/hl2_sound_vo_english.vpk
game |appid_243750|hl2/hl2_sound_misc.vpk
game+vgui |appid_243750|hl2/hl2_misc.vpk
platform+vgui |appid_243750|platform/platform_misc.vpk
// Last, mount in shared HL2 and TF2 loose files
game |appid_440|tf
game |appid_243750|hl2
platform |appid_243750|platform
// Random files downloaded from gameservers go into a seperate directory, so
// that it's easy to keep those files segregated from the official game files
// or customizations intentially installed by the user.
//
// This directory is searched LAST. If you visit a server and download
// a custom model, etc, we don't want that file to override the default
// game file indefinitely (after you have left the server). Servers CAN have
// custom content that overrides the default game files, it just needs to be
// packed up in the .bsp file so that it will be mounted as a map search pack.
// The map search pack is mounted at the top of the search path list,
// but only while you are connected that server and on that map.
game+download mod_tf/download
}
}
}
```
--------------------------------
### StopAnimation Command
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/game/mod_hl2mp/scripts/HudAnimations.txt
Stops all animations targeting a specific variable within a given panel, starting from a specified time.
```script
StopAnimation
```
--------------------------------
### Enable ASan and UBSan
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/CONTRIBUTING.md
Configure the build to include AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan) for detecting memory and undefined behavior errors.
```bash
meson configure -Db_sanitize=address,undefined
```
--------------------------------
### RunEvent Command
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/game/mod_hl2mp/scripts/HudAnimations.txt
Starts another animation event at a specified time. This allows for chaining or triggering animations sequentially.
```script
RunEvent
```
--------------------------------
### Generate Configure Script
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/README.md
Run this command if you are building from a GitHub source to generate the configure script.
```bash
$ ./autogen.sh
```
--------------------------------
### Get Modification Time
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the modification time of the PNG image. It is recommended to call this function after decoding the image.
```c
int spng_get_time(spng_ctx *ctx, struct spng_time *time)
```
--------------------------------
### Get sRGB Rendering Intent
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the sRGB rendering intent of the image. This value specifies how colors should be mapped.
```c
int spng_get_srgb(spng_ctx *ctx, uint8_t *rendering_intent)
```
--------------------------------
### Defining and Using Custom Field Options in Protobuf
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/CHANGES.txt
Demonstrates how to define custom annotations (options) for .proto file definitions and how to access these options via the message descriptor in C++.
```protobuf
import "google/protobuf/descriptor.proto"
extend google.protobuf.FieldOptions {
optional string foo = 12345;
}
message MyMessage {
optional int32 some_field = 1 [(foo) = "bar"]
}
```
```cpp
const FieldDescriptor* field =
MyMessage::descriptor()->FindFieldByName("some_field");
assert(field->options().GetExtension(foo) == "bar");
```
--------------------------------
### Freeing Decompressed Buffer
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/7zC.txt
Example of how to free the memory allocated for a decompressed file after extraction. This is crucial for preventing memory leaks.
```c
allocImp.Free(outBuffer);
```
--------------------------------
### Progressive Decoding - Non-Interlaced
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/decode.md
Example of progressive decoding for non-interlaced images using `spng_decode_row()`. The loop continues until `SPNG_EOI` is returned.
```c
int error;
size_t image_width = image_size / ihdr.height;
for(i = 0; i < ihdr.height; i++)
{
void *row = image + image_width * i;
error = spng_decode_row(ctx, row, image_width);
if(error) break;
}
if(error == SPNG_EOI) /* success */
```
--------------------------------
### Decode PNG Image with libspng
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/README.md
Demonstrates the basic steps to decode a PNG image using libspng. This includes creating a context, setting the input buffer, determining output size, and decoding the image to RGBA8 format.
```c
#include
/* Create a decoder context */
spng_ctx *ctx = spng_ctx_new(0);
/* Set an input buffer */
spng_set_png_buffer(ctx, buf, buf_size);
/* Determine output image size */
spng_decoded_image_size(ctx, SPNG_FMT_RGBA8, &out_size);
/* Decode to 8-bit RGBA */
spng_decode_image(ctx, out, out_size, SPNG_FMT_RGBA8, 0);
/* Free context memory */
spng_ctx_free(ctx);
```
--------------------------------
### Get ICC Profile
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the ICC profile information from the PNG image. Note that ICC profiles are not validated by this function.
```c
int spng_get_iccp(spng_ctx *ctx, struct spng_iccp *iccp)
```
--------------------------------
### Configure with Custom Protoc Executable for Cross-Compiling
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/README.md
When cross-compiling, use the --with-protoc option to specify an already built protoc executable for the host machine.
```bash
./configure --with-protoc=protoc
```
--------------------------------
### Get PNG Gamma Value
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the gamma value of the image. The gamma value is stored in a double-precision floating-point number.
```c
int spng_get_gama(spng_ctx *ctx, double *gamma)
```
--------------------------------
### Get PNG Option Value
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/context.md
Retrieves the value for a given spng_option from the spng_ctx. Refer to decode.md and encode.md for option details.
```c
int spng_get_option(spng_ctx *ctx, enum spng_option option, int *value)
```
--------------------------------
### Launch Mod on Linux
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/README.md
Navigate to the 'game' directory and run this command to launch your mod project using its build launcher on Linux.
```bash
./mod_tf
```
--------------------------------
### Create SFX to Open a File
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/installer.txt
Commands to create a self-extracting archive that opens a text file.
```bash
7zr a h.7z readme.txt -mx
copy /b 7zS2.sfx + h.7z 7zTxt.exe
7zTxt.exe
```
--------------------------------
### Get PNG Image Transparency
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the image transparency information from a PNG context. This function reads chunks up to the first IDAT.
```c
int spng_get_trns(spng_ctx *ctx, struct spng_trns *trns)
```
--------------------------------
### Fork and Clone Repository
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/CONTRIBUTING.md
Clone your forked repository and set up the upstream remote for tracking the original project.
```bash
git clone https://github.com/username/libspng.git
cd libspng
git remote add upstream https://github.com/randy408/libspng.git
```
--------------------------------
### Get PNG Image Palette
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the image palette information from a PNG context. This function reads chunks up to the first IDAT.
```c
int spng_get_plte(spng_ctx *ctx, struct spng_plte *plte)
```
--------------------------------
### Create Debug Build with Dev Features
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/CONTRIBUTING.md
Configure and build the project with development features enabled and debug symbols.
```bash
meson -Ddev_build=true --buildtype=debug build
cd build
```
--------------------------------
### Get PNG Image Header
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/chunk.md
Retrieves the image header information from a PNG context. This function reads chunks up to the first IDAT.
```c
int spng_get_ihdr(spng_ctx *ctx, struct spng_ihdr *ihdr)
```
--------------------------------
### Configure with Specific Protoc Path for Cross-Compiling
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/README.md
Provide a direct path to a protoc executable for cross-compiling if it's not in the system's PATH.
```bash
./configure --with-protoc=../host/src/protoc
```
--------------------------------
### Get libspng Version String
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/libspng/docs/version.md
Retrieves the library version as a human-readable string. This function is useful for logging or displaying the current libspng version.
```c
const char *spng_version_string(void)
```
--------------------------------
### 7-Zip Compression with LZMA (No Filter)
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/utils/lzma/DOC/lzma-sdk.txt
Demonstrates compressing data using 7-Zip with the LZMA method without any pre-compression filters.
```bash
7z a a1.7z a.bin -m0=lzma
```
--------------------------------
### Enable C++ Implementation Environment Variable
Source: https://github.com/valvesoftware/source-sdk-2013/blob/master/src/thirdparty/protobuf-2.6.1/python/README.txt
Export environment variables to enable the C++ implementation of the Protocol Buffers Python runtime. This should be done before running setup.py and at runtime.
```bash
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2
```