SetColor() public method

public SetColor ( int x, int y, GBA.Color value ) : void
x int
y int
value GBA.Color
return void
コード例 #1
0
        void Core_DrawLayer(GBA.Bitmap result, GBA.Image image, Rectangle region, int offsetX, int offsetY)
        {
            int index;
            int pixel;

            for (int y = 0; y < region.Height; y++)
            {
                for (int x = 0; x < region.Width; x++)
                {
                    index = ((region.X + x) / 2) + ((region.Y + y) * (image.Width / 2));
                    pixel = (x % 2 == 0) ?
                            (image.Bytes[index] & 0x0F) :
                            (image.Bytes[index] & 0xF0) >> 4;
                    if (pixel != 0)
                    {
                        result.SetColor(offsetX + x, offsetY + y, image.Colors[pixel]);
                    }
                }
            }
        }
コード例 #2
0
        void Core_LoadMap_Units(GBA.Bitmap result)
        {
            try
            {
                Pointer address_mapsprites = Core.GetPointer("Map Sprite Idle Array");
                Pointer address_classes    = Core.GetPointer("Class Array");
                Pointer address;
                byte    palette_index;
                byte    palette_amount = 4;
                address = Core.GetPointer("Map Sprite Palettes");
                byte[][] palettes = new byte[palette_amount][];
                for (int i = 0; i < palette_amount; i++)
                {
                    palettes[i] = Core.ReadData(address + i * Palette.LENGTH, Palette.LENGTH);
                    result.Colors.Add(new Palette(palettes[i]));
                }
                int       class_length = (Core.CurrentROM is FE6 ? 72 : 84);
                GBA.Image image;
                byte      unitclass;
                byte      mapsprite;
                byte      size;
                Tileset   tileset;
                int       offsetX;
                int       offsetY;
                int       index;
                for (int i = 0; i < EventList.Count; i++)
                {
                    if (EventList[i].Command == "UNIT" &&
                        EventList[i].Label != null)
                    {
                        index = UnitEvents_ListBox.Items.IndexOf(EventList[i].Label);
                        if (index == -1)
                        {
                            continue;
                        }
                        else if (!UnitEvents_ListBox.GetItemChecked(index))
                        {
                            continue;
                        }
                        unitclass     = (byte)EventList[i].Arguments[1];
                        mapsprite     = Core.ReadByte(address_classes + 6 + unitclass * class_length);
                        address       = address_mapsprites + mapsprite * 8;
                        size          = Core.ReadByte(address + 2);
                        tileset       = new Tileset(Core.ReadData(Core.ReadPointer(address + 4), 0));
                        palette_index = (byte)(EventList[i].Arguments[3] & 6);
                        if (palette_index > 2)
                        {
                            palette_index -= 3;
                        }
                        switch (size)
                        {
                        case 0x00: image = tileset.ToImage(2, 2, palettes[palette_index]); break;

                        case 0x01: image = tileset.ToImage(2, 4, palettes[palette_index]); break;

                        case 0x02: image = tileset.ToImage(4, 4, palettes[palette_index]); break;

                        default: image = null; break;
                        }
                        if (image != null)
                        {
                            offsetX  = (int)(EventList[i].Arguments[UNIT_argX] * 16);
                            offsetY  = (int)(EventList[i].Arguments[UNIT_argY] * 16);
                            offsetX -= (size == 0x02 ? 8 : 0);
                            offsetY -= (size == 0x00 ? 0 : 16);
                            int pixel;
                            for (int y = 0; y < image.Height; y++)
                            {
                                for (int x = 0; x < image.Width; x++)
                                {
                                    index = (x / 2) + y * (image.Width / 2);
                                    pixel = (x % 2 == 0) ?
                                            (image.Bytes[index] & 0x0F) :
                                            (image.Bytes[index] & 0xF0) >> 4;
                                    if (pixel != 0 &&
                                        offsetX + x >= 0 && offsetX + x < result.Width &&
                                        offsetY + y >= 0 && offsetY + y < result.Height)
                                    {
                                        result.SetColor(offsetX + x, offsetY + y, image.Colors[pixel]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Program.ShowError("Could not load the units to display on the map.", ex);
            }
        }