public void OneImageToRuleThemAll(ImageFile im, string archiveDir, byte[] imgData)
{
ImageMipMapHandler imgMipMap = new ImageMipMapHandler("", imgData);
if (Class == class2 || Class == class3)
ChangeFormat(imgMipMap.imageList[0].format);
// starts from the smaller image
for (int i = imgMipMap.imageList.Count - 1; i >= 0; i--)
{
ImageFile newImageFile = imgMipMap.imageList[i];
ImageEngineFormat imgFileFormat = Textures.Methods.ParseFormat(newImageFile.format);
if (texFormat != imgFileFormat)
throw new FormatException("Different image format, original is " + texFormat + ", new is " + newImageFile.subtype());
// if the image size exists inside the texture2d image list then we have to replace it
if (privateimgList.Exists(img => img.imgSize == newImageFile.imgSize))
{
// ...but at least for now I can reuse my replaceImage function... ;)
replaceImage(newImageFile.imgSize.ToString(), newImageFile, archiveDir);
}
else if (newImageFile.imgSize.width > privateimgList[0].imgSize.width) // if the image doesn't exists then we have to add it
{
// ...and use my addBiggerImage function! :P
addBiggerImage(newImageFile, archiveDir);
}
//else
// addMissingImage(newImageFile.imgSize.ToString(), newImageFile.fileName);
// else ignore the image
}
// Remove higher res versions and fix up properties
while (privateimgList[0].imgSize.width > imgMipMap.imageList[0].imgSize.width)
//while (imgMipMap.imageList.Count + 2 < imgList.Count)
{
privateimgList.RemoveAt(0);
numMipMaps--;
}
if (properties.ContainsKey("SizeX"))
properties["SizeX"].Value.IntValue = (int)privateimgList[0].imgSize.width;
if (properties.ContainsKey("SizeY"))
properties["SizeY"].Value.IntValue = (int)privateimgList[0].imgSize.height;
if (properties.ContainsKey("MipTailBaseIdx"))
properties["MipTailBaseIdx"].Value.IntValue = privateimgList.Count + 1;
}