bool LoadTextureFromName(string filename, int texture, lwTexInfo texInfo) { try { Bitmap bmp = LoadBitmapByName(filename); if (texInfo.colorkey_type == lwColorKeyTypeEnum.COLORKEY_TYPE_COLOR) bmp.MakeTransparent(Color.FromArgb(texInfo.colorkey.a, texInfo.colorkey.r, texInfo.colorkey.g, texInfo.colorkey.b)); LoadTextureFromBitmap(bmp, texture); return true; } catch { return false; } }
bool LoadTextureFromStream(System.IO.Stream stream, int texture, lwTexInfo texInfo) { try { Bitmap bmp = LoadBitmapByStream(stream); if (texInfo.colorkey_type == lwColorKeyTypeEnum.COLORKEY_TYPE_COLOR) bmp.MakeTransparent(Color.FromArgb(texInfo.colorkey.a, texInfo.colorkey.r, texInfo.colorkey.g, texInfo.colorkey.b)); LoadTextureFromBitmap(bmp, texture); return true; } catch { return false; } }
bool LoadTexture(string filename, int texture, lwTexInfo texInfo) { filename = GetRightTextureName(filename); if (filename == null) return false; byte[] data = System.IO.File.ReadAllBytes(filename); System.IO.MemoryStream ms = new System.IO.MemoryStream(data); if (LoadTextureFromStream(ms, texture, texInfo)) { ms.Close(); return true; } ms.Close(); data = ProcessTextureData(data); ms = new System.IO.MemoryStream(data); if (LoadTextureFromStream(ms, texture, texInfo)) { ms.Close(); return true; } ms.Close(); return false; }