| 13 | UOFileReader g_UOFileReader; |
| 14 | |
| 15 | std::vector<uint16_t> UOFileReader::GetGumpPixels(CIndexObject &io) |
| 16 | { |
| 17 | size_t dataStart = io.Address; |
| 18 | uint32_t *lookupList = (uint32_t *)dataStart; |
| 19 | |
| 20 | int blocksize = io.Width * io.Height; |
| 21 | |
| 22 | std::vector<uint16_t> pixels; |
| 23 | |
| 24 | if (blocksize == 0) |
| 25 | { |
| 26 | Warning(Data, "UOFileReader::GetGumpPixels bad size:%i, %i", io.Width, io.Height); |
| 27 | return pixels; |
| 28 | } |
| 29 | |
| 30 | pixels.resize(blocksize); |
| 31 | |
| 32 | if (pixels.size() != blocksize) |
| 33 | { |
| 34 | Warning( |
| 35 | Data, "Allocation pixels memory for GetGumpPixels failed (want size: %i)", blocksize); |
| 36 | return pixels; |
| 37 | } |
| 38 | |
| 39 | uint16_t color = io.Color; |
| 40 | |
| 41 | for (int y = 0; y < io.Height; y++) |
| 42 | { |
| 43 | int gSize = 0; |
| 44 | |
| 45 | if (y < io.Height - 1) |
| 46 | { |
| 47 | gSize = lookupList[y + 1] - lookupList[y]; |
| 48 | } |
| 49 | else |
| 50 | { |
| 51 | gSize = (io.DataSize / 4) - lookupList[y]; |
| 52 | } |
| 53 | |
| 54 | GUMP_BLOCK *gmul = (GUMP_BLOCK *)(dataStart + lookupList[y] * 4); |
| 55 | int pos = (int)y * io.Width; |
| 56 | |
| 57 | for (int i = 0; i < gSize; i++) |
| 58 | { |
| 59 | uint16_t val = gmul[i].Value; |
| 60 | |
| 61 | if ((color != 0u) && (val != 0u)) |
| 62 | { |
| 63 | val = g_ColorManager.GetColor16(val, color); |
| 64 | } |
| 65 | |
| 66 | uint16_t a = (val != 0u ? 0x8000 : 0) | val; |
| 67 | |
| 68 | int count = gmul[i].Run; |
| 69 | |
| 70 | for (int j = 0; j < count; j++) |
| 71 | { |
| 72 | pixels[pos++] = a; |
no test coverage detected