Skip to content

Commit

Permalink
Merge pull request #313 from Kopernicus/palette_mipmaps
Browse files Browse the repository at this point in the history
add support for mipmaps (kind of)
Sigma88 authored Oct 3, 2018

Verified

This commit was signed with the committer’s verified signature.
makenowjust Hiroya Fujinami
2 parents c6d8417 + c5efd32 commit cc0dda3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Kopernicus.OnDemand/OnDemandStorage.cs
Original file line number Diff line number Diff line change
@@ -443,8 +443,9 @@ public static Texture2D LoadTexture(String path, Boolean compress, Boolean uploa
int width = (int) dDSHeader.dwWidth;
int height = (int) dDSHeader.dwHeight;
long length = new FileInfo(path).Length;
int pixels = width * height * bpp / 8 + 4 * colors;

if (length == width * height * bpp / 8 + 4 * colors + 128)
if (length - 128 >= pixels)
{
byte[] data = LoadRestOfReader(binaryReader);

@@ -457,14 +458,14 @@ public static Texture2D LoadTexture(String path, Boolean compress, Boolean uploa
data[i + 3]);
}

for (int i = 4 * colors; i < data.Length; i++)
for (int i = 4 * colors; i < pixels; i++)
{
image[(i - 4 * colors) * 8 / bpp] = palette[data[i] * colors / 256];
if (bpp == 4)
image[(i - 64) * 2 + 1] = palette[data[i] % 16];
}

map = new Texture2D(width, height, TextureFormat.ARGB32, mipmap);
map = new Texture2D(width, height, TextureFormat.ARGB32, false);
map.SetPixels(image);
}
else

0 comments on commit cc0dda3

Please sign in to comment.