libragephoto: add ragephoto Python Package
- separate RagePhoto and RagePhoto-Extract sources
This commit is contained in:
parent
9a5bcabf8c
commit
0f1cfe630b
27 changed files with 503 additions and 50 deletions
82
src/extract/RagePhoto-Extract.c
Normal file
82
src/extract/RagePhoto-Extract.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "RagePhoto.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s [photo] [jpegout]\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Initialise RagePhoto
|
||||
ragephoto_t ragephoto_in = ragephoto_open();
|
||||
|
||||
// Load Photo
|
||||
const int loaded = ragephoto_loadfile(ragephoto_in, argv[1]);
|
||||
|
||||
if (loaded != 1) {
|
||||
const int32_t error = ragephoto_error(ragephoto_in);
|
||||
if (error == RAGEPHOTO_ERROR_UNINITIALISED) {
|
||||
printf("Failed to open file: %s\n", argv[1]);
|
||||
ragephoto_close(ragephoto_in);
|
||||
return 1;
|
||||
}
|
||||
else if (error <= RAGEPHOTO_ERROR_PHOTOREADERROR) {
|
||||
printf("Failed to load photo\n");
|
||||
ragephoto_close(ragephoto_in);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Write jpeg
|
||||
#ifdef _WIN32
|
||||
FILE *file = NULL;
|
||||
fopen_s(&file, argv[2], "wb");
|
||||
#else
|
||||
FILE *file = fopen(argv[2], "wb");
|
||||
#endif
|
||||
if (!file) {
|
||||
printf("Failed to write file: %s\n", argv[2]);
|
||||
ragephoto_close(ragephoto_in);
|
||||
return 1;
|
||||
}
|
||||
const size_t jpegSize = ragephoto_getphotosize(ragephoto_in);
|
||||
const size_t fileSize = fwrite(ragephoto_getphotojpeg(ragephoto_in), sizeof(char), jpegSize, file);
|
||||
fclose(file);
|
||||
|
||||
if (fileSize != jpegSize) {
|
||||
printf("Failed to write file: %s\n", argv[2]);
|
||||
ragephoto_close(ragephoto_in);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const uint32_t photoFormat = ragephoto_getphotoformat(ragephoto_in);
|
||||
if (photoFormat == RAGEPHOTO_FORMAT_GTA5)
|
||||
printf("GTA V Photo successfully exported\n");
|
||||
else if (photoFormat == RAGEPHOTO_FORMAT_RDR2)
|
||||
printf("RDR 2 Photo successfully exported\n");
|
||||
else
|
||||
printf("Photo successfully exported\n");
|
||||
|
||||
ragephoto_close(ragephoto_in);
|
||||
|
||||
return 0;
|
||||
}
|
71
src/extract/RagePhoto-Extract.cpp
Normal file
71
src/extract/RagePhoto-Extract.cpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <RagePhotoB>
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
std::cout << "Usage: " << argv[0] << " [photo] [jpegout]" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Initialise RagePhoto
|
||||
RagePhotoB ragePhoto;
|
||||
|
||||
// Load Photo
|
||||
const bool loaded = ragePhoto.loadFile(argv[1]);
|
||||
|
||||
if (!loaded) {
|
||||
const int32_t error = ragePhoto.error();
|
||||
if (error == RagePhotoB::Uninitialised) {
|
||||
std::cout << "Failed to open file: " << argv[1] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else if (error <= RagePhotoB::PhotoReadError) {
|
||||
std::cout << "Failed to load photo" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Write jpeg
|
||||
std::ofstream ofs(argv[2], std::ios::out | std::ios::binary | std::ios::trunc);
|
||||
if (!ofs.is_open()) {
|
||||
std::cout << "Failed to write file: " << argv[2] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
ofs << ragePhoto.jpeg();
|
||||
const bool ok = ofs.good();
|
||||
ofs.close();
|
||||
|
||||
if (!ok) {
|
||||
std::cout << "Failed to write file: " << argv[2] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
const uint32_t photoFormat = ragePhoto.format();
|
||||
if (photoFormat == RagePhotoB::GTA5)
|
||||
std::cout << "GTA V Photo successfully exported" << std::endl;
|
||||
else if (photoFormat == RagePhotoB::RDR2)
|
||||
std::cout << "RDR 2 Photo successfully exported" << std::endl;
|
||||
else
|
||||
std::cout << "Photo successfully exported" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
29
src/extract/ragephoto-extract.rc.in
Normal file
29
src/extract/ragephoto-extract.rc.in
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <windows.h>
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @ragephoto_VERSION_MAJOR@, @ragephoto_VERSION_MINOR@, @ragephoto_VERSION_PATCH@, 0
|
||||
PRODUCTVERSION @ragephoto_VERSION_MAJOR@, @ragephoto_VERSION_MINOR@, @ragephoto_VERSION_PATCH@, 0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0809, 1200
|
||||
END
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Syping"
|
||||
VALUE "FileDescription", "RAGE Photo Extract Tool for GTA V and RDR 2"
|
||||
VALUE "FileVersion", "@ragephoto_VERSION@"
|
||||
VALUE "InternalName", "ragephoto-extract"
|
||||
VALUE "LegalCopyright", "Copyright © @ragephoto_BUILD_YEAR@ Syping"
|
||||
VALUE "OriginalFilename", "ragephoto-extract.exe"
|
||||
VALUE "ProductName", "ragephoto-extract"
|
||||
VALUE "ProductVersion", "@ragephoto_VERSION@"
|
||||
END
|
||||
END
|
||||
END
|
Loading…
Add table
Add a link
Reference in a new issue