Skip to content

Commit

Permalink
Merge pull request #334 from carboncopies/333-cleanup-extra-comments
Browse files Browse the repository at this point in the history
333 cleanup extra comments
  • Loading branch information
datacrystals authored Aug 28, 2022
2 parents 3654070 + 5d6fbe9 commit 25d2b46
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,33 +275,11 @@ void ERS_CLASS_ExternalModelLoader::ProcessModelTextures(ERS_STRUCT_ModelWriterD

if (Success || SecondTryStatus) {
SystemUtils_->Logger_->Log(std::string("Starting Loading Texture '") + TexturePath + "'", 3);

Lucifer::Image LuciferImage;
ImageProcessor_->Load(IOData.Data.get(), IOData.Size_B, LuciferImage);
FIBITMAP* Image = Lucifer::Lucifer_CreateFIBitmapFromImage(LuciferImage);

// ImageFutures.push_back(std::make_pair(TexturePath, std::async(std::launch::async,
// [&IOData, StartArg = 1]() {
// FIMEMORY* FIImageData = FreeImage_OpenMemory(IOData.Data.get(), IOData.Size_B);
// FREE_IMAGE_FORMAT Format = FreeImage_GetFileTypeFromMemory(FIImageData);
// FIBITMAP* RawImage = FreeImage_LoadFromMemory(Format, FIImageData);
// FreeImage_CloseMemory(FIImageData);

// FIBITMAP* Image = FreeImage_ConvertTo32Bits(RawImage);
// FreeImage_Unload(RawImage);
// std::cout<<FreeImage_GetWidth(Image)<<std::endl;
// return Image;
// }
// )));


// FIMEMORY* FIImageData = FreeImage_OpenMemory(IOData.Data.get(), IOData.Size_B);
// FREE_IMAGE_FORMAT Format = FreeImage_GetFileTypeFromMemory(FIImageData);
// FIBITMAP* Image = FreeImage_LoadFromMemory(Format, FIImageData);
// FreeImage_CloseMemory(FIImageData);

FIBITMAP* Image;
{
Lucifer::Image LuciferImage;
ImageProcessor_->Load(IOData.Data.get(), IOData.Size_B, LuciferImage);
Image = Lucifer::Lucifer_CreateFIBitmapFromImage(LuciferImage);
}

int Width, Height;
Width = FreeImage_GetWidth(Image);
Expand All @@ -310,30 +288,16 @@ void ERS_CLASS_ExternalModelLoader::ProcessModelTextures(ERS_STRUCT_ModelWriterD
SystemUtils_->Logger_->Log("Error Loading Image, Resulting Raw Image Has Invalid Size!", 7);
}

//FIBITMAP* Image = FreeImage_ConvertTo32Bits(RawImage);
//FreeImage_Unload(RawImage);

std::string Size = "(" + std::to_string(FreeImage_GetWidth(Image)) + "x" + std::to_string(FreeImage_GetWidth(Image)) + ")";
SystemUtils_->Logger_->Log(std::string("Loaded Image Texture Of Size ") + Size, 2);

ImageBytes.push_back(std::make_pair(TexturePath, Image));
}
}

// Get Futures
// std::vector<std::pair<std::string, FIBITMAP*>> ImageBytes;
// for (unsigned int i = 0; i < ImageFutures.size(); i++) {
// std::string ImagePath = ImageFutures[i].first;
// SystemUtils_->Logger_->Log(std::string("Getting Image Bitmap From Thread For Texture '") + ImagePath + "'", 4);
// FIBITMAP* Image = ImageFutures[i].second.get();
// ImageBytes.push_back(std::make_pair(ImagePath, Image));
// }


// Remove Duplicate Stuff (Like Alpha Maps), Just Generally Consolidate Stuff
MergeTextures(Data.Model, &ImageBytes);


Data.ImageBytes = ImageBytes;

}
Expand Down
14 changes: 1 addition & 13 deletions Source/Core/Writers/ERS_ModelWriter/ERS_ModelWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,7 @@ void ERS_CLASS_ModelWriter::WriteTextures(ERS_STRUCT_ModelWriterData &Data, std:
Logger_->Log(std::string("Resizing Texture Image To Size '") + std::to_string(TargetX) + "," + std::to_string(TargetY) + "'", 4);
FIBITMAP* NewImage = FreeImage_Rescale(Image, TargetX, TargetY);

// Swap Colors From RGB To BGR
FIBITMAP* Red = FreeImage_GetChannel(NewImage, FICC_RED);
FIBITMAP* Green = FreeImage_GetChannel(NewImage, FICC_GREEN);
FIBITMAP* Blue = FreeImage_GetChannel(NewImage, FICC_BLUE);
FIBITMAP* Alpha = FreeImage_GetChannel(NewImage, FICC_ALPHA);
FreeImage_SetChannel(NewImage, Red, FICC_BLUE);
FreeImage_SetChannel(NewImage, Green, FICC_GREEN);
FreeImage_SetChannel(NewImage, Blue, FICC_RED);
FreeImage_SetChannel(NewImage, Alpha, FICC_ALPHA);
FreeImage_Unload(Red);
FreeImage_Unload(Green);
FreeImage_Unload(Blue);
FreeImage_Unload(Alpha);



// Save Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ LoadingStatus Lucifer_LoadFreeImage(unsigned char* ImageData, unsigned long Size
FIBITMAP* FIImage = FreeImage_LoadFromMemory(Format, FIImageData);
FreeImage_CloseMemory(FIImageData);


// Swap Colors From RGB To BGR
FIBITMAP* Red = FreeImage_GetChannel(FIImage, FICC_RED);
FIBITMAP* Green = FreeImage_GetChannel(FIImage, FICC_GREEN);
FIBITMAP* Blue = FreeImage_GetChannel(FIImage, FICC_BLUE);
FIBITMAP* Alpha = FreeImage_GetChannel(FIImage, FICC_ALPHA);
FreeImage_SetChannel(FIImage, Red, FICC_BLUE);
FreeImage_SetChannel(FIImage, Green, FICC_GREEN);
FreeImage_SetChannel(FIImage, Blue, FICC_RED);
FreeImage_SetChannel(FIImage, Alpha, FICC_ALPHA);
FreeImage_Unload(Red);
FreeImage_Unload(Green);
FreeImage_Unload(Blue);
FreeImage_Unload(Alpha);


// Get Metadata
int Width, Height, Line;
Width = FreeImage_GetWidth(FIImage);
Height = FreeImage_GetHeight(FIImage);
Expand Down

0 comments on commit 25d2b46

Please sign in to comment.