public void singleImageUpscale(string imagePathToAdd, string archiveDir)
{
ImageSize biggerImageSizeOnList = imgList.Max(image => image.imgSize);
// check if replacing image is supported
ImageFile imgFile;
string fileFormat = Path.GetExtension(imagePathToAdd);
switch (fileFormat)
{
case ".dds": imgFile = new DDS(imagePathToAdd, null); break;
case ".DDS": imgFile = new DDS(imagePathToAdd, null); break;
default: throw new FormatException(fileFormat + " image extension not supported");
}
if (texFormat == "PF_NormalMap_HQ")
{
if (imgFile.format != "ATI2")
throw new FormatException("Different image format, original is " + texFormat + ", new is " + imgFile.subtype());
}
else if (String.Compare(texFormat, "PF_" + imgFile.format, true) != 0 &&
String.Compare(texFormat, imgFile.format, true) != 0)
{
throw new FormatException("Different image format, original is " + texFormat + ", new is " + imgFile.subtype());
}
// !!! warning, this method breaks consistency between imgList and imageData[] !!!
ImageInfo newImgInfo = new ImageInfo();
newImgInfo.storageType = imgList.Find(img => img.storageType != storage.empty && img.storageType != storage.pccSto).storageType;
newImgInfo.imgSize = imgFile.imgSize;
newImgInfo.uncSize = imgFile.resize().Length;
newImgInfo.cprSize = 0x00; // not yet filled
newImgInfo.offset = 0x00; // not yet filled
imgList.RemoveAt(0); // Remove old single image and add new one
imgList.Add(newImgInfo);
//now I let believe the program that I'm doing an image replace, saving lot of code ;)
replaceImage2(newImgInfo.imgSize.ToString(), imagePathToAdd, archiveDir);
// update Sizes
properties["SizeX"].Value.IntValue = (int)newImgInfo.imgSize.width;
properties["SizeY"].Value.IntValue = (int)newImgInfo.imgSize.height;
}