Exemplo n.º 1
0
        public static void DrawRSImage(RSImage s, int x, int y)
        {
            x += s.XOffset;
            y += s.YOffset;
            int l  = x + y * DrawingArea.width;
            int i1 = 0;
            int j1 = s.Height;
            int k1 = s.Width;
            int l1 = DrawingArea.width - k1;
            int i2 = 0;

            if (y < DrawingArea.topY)
            {
                int j2 = DrawingArea.topY - y;
                j1 -= j2;
                y   = DrawingArea.topY;
                i1 += j2 * k1;
                l  += j2 * DrawingArea.width;
            }
            if (y + j1 > DrawingArea.bottomY)
            {
                j1 -= (y + j1) - DrawingArea.bottomY;
            }
            if (x < DrawingArea.topX)
            {
                int k2 = DrawingArea.topX - x;
                k1 -= k2;
                x   = DrawingArea.topX;
                i1 += k2;
                l  += k2;
                i2 += k2;
                l1 += k2;
            }
            if (x + k1 > DrawingArea.bottomX)
            {
                int l2 = (x + k1) - DrawingArea.bottomX;
                k1 -= l2;
                i2 += l2;
                l1 += l2;
            }
            if (!(k1 <= 0 || j1 <= 0))
            {
                DrawPixels(s.Pixels, i1, l, k1, j1, l1, i2);
            }
        }
Exemplo n.º 2
0
        public void PluginSelected()
        {
            RSImage image = new RSImage(Cache, Node, Data, 0);

            ((PictureBox)Controls[0]).Image = image.GeneratePaletteBitmap();
            if (((PictureBox)Controls[0]).Image == null)
            {
                Controls[0].Visible = false;
                Controls[1].Visible = true;
                FileExtensions      = "";
            }
            else
            {
                Controls[0].Visible = true;
                Controls[1].Visible = false;
                FileExtensions      = "";
            }
        }
Exemplo n.º 3
0
        public void PluginSelected()
        {
            RSImage image = new RSImage(Cache, Node, Data, (int)((NumericUpDown)ToolControls[1]).Value);

            ((PictureBox)Controls[0]).Image = image.GenerateBitmap();
            if (((PictureBox)Controls[0]).Image == null)
            {
                Controls[0].Visible = false;
                Controls[1].Visible = true;
                FileExtensions      = "";
            }
            else
            {
                Controls[0].Visible = true;
                Controls[1].Visible = false;
                FileExtensions      = "PNG Image (*.png)|*.png";
            }
        }
Exemplo n.º 4
0
 public bool OnImport(string filename)
 {
     try
     {
         Exception e         = null;
         RSImage   new_image = new RSImage(filename, out e);
         if (e != null)
         {
             throw e;
         }
         new_image.Write(Cache, Node, Data);
         Data = Cache.SubArchives[Node.SubArchive].ExtractFile(Node.FileIndex);
         ((PictureBox)Controls[0]).Image = new_image.GenerateBitmap();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error importing image.\n\n" + ex.Message + "\n\n" + ex.StackTrace, "Error Importing Image", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
 }
        public static RSImage GetModelSprite(int id, int amount, int selection_color)
        {
            Color          k_color = Color.FromArgb(selection_color);
            ItemDefinition itemDef = GetItem(id);

            if (itemDef.StackedItemIDs == null)
            {
                amount = -1;
            }
            if (amount > 1)
            {
                int i1 = -1;
                for (int j1 = 0; j1 < 10; j1++)
                {
                    if (amount >= itemDef.StackChangeAmounts[j1] && itemDef.StackChangeAmounts[j1] != 0)
                    {
                        i1 = itemDef.StackedItemIDs[j1];
                    }
                }

                if (i1 != -1)
                {
                    itemDef = GetItem(i1);
                }
            }
            Model model = itemDef.GetModel(1);

            if (model == null)
            {
                return(null);
            }
            RSImage sprite = null;

            if (itemDef.NotedModelItemID != -1)
            {
                sprite = GetModelSprite(itemDef.NotedID, 10, -1);
                if (sprite == null)
                {
                    return(null);
                }
            }
            RSImage sprite2 = new RSImage(32, 32);
            int     k1      = Rasterizer.center_x;
            int     l1      = Rasterizer.center_y;

            int[] ai  = Rasterizer.line_pixel_locations;
            int[] ai1 = DrawingArea.pixels;
            int   i2  = DrawingArea.width;
            int   j2  = DrawingArea.height;
            int   k2  = DrawingArea.topX;
            int   l2  = DrawingArea.bottomX;
            int   i3  = DrawingArea.topY;
            int   j3  = DrawingArea.bottomY;

            Rasterizer.aBoolean1464 = false;
            DrawingArea.initDrawingArea(32, 32, new int[32 * 32]);
            DrawingArea.method336(32, 0, 0, 0, 32);
            Rasterizer.method364();
            int k3 = itemDef.Zoom;

            if (selection_color == -1)
            {
                k3 = (int)((double)k3 * 1.5D);
            }
            if (selection_color > 0)
            {
                k3 = (int)((double)k3 * 1.04D);
            }
            int l3 = Rasterizer.SIN[itemDef.RotationX] * k3 >> 16;
            int i4 = Rasterizer.COS[itemDef.RotationX] * k3 >> 16;

            model.Render(itemDef.RotationY, itemDef.RotationZ, itemDef.RotationX, itemDef.SpriteX, l3 + model.modelHeight / 2 + itemDef.SpriteY, i4 + itemDef.SpriteY);

            //draw the black outline
            for (int i5 = 31; i5 >= 0; i5--)
            {
                for (int j4 = 31; j4 >= 0; j4--)
                {
                    if (DrawingArea.pixels[i5 + j4 * 32] == 0)
                    {
                        if (i5 > 0 && DrawingArea.pixels[(i5 - 1) + j4 * 32] > 1)
                        {
                            DrawingArea.pixels[i5 + j4 * 32] = 1;
                        }
                        else if (j4 > 0 && DrawingArea.pixels[i5 + (j4 - 1) * 32] > 1)
                        {
                            DrawingArea.pixels[i5 + j4 * 32] = 1;
                        }
                        else if (i5 < 31 && DrawingArea.pixels[i5 + 1 + j4 * 32] > 1)
                        {
                            DrawingArea.pixels[i5 + j4 * 32] = 1;
                        }
                        else if (j4 < 31 && DrawingArea.pixels[i5 + (j4 + 1) * 32] > 1)
                        {
                            DrawingArea.pixels[i5 + j4 * 32] = 1;
                        }
                    }
                }
            }

            //draw the selection outline or shadow
            if (selection_color > 0)             //selection outline
            {
                for (int j5 = 31; j5 >= 0; j5--)
                {
                    for (int k4 = 31; k4 >= 0; k4--)
                    {
                        if (DrawingArea.pixels[j5 + k4 * 32] == 0)
                        {
                            if (j5 > 0 && DrawingArea.pixels[(j5 - 1) + k4 * 32] == 1)
                            {
                                DrawingArea.pixels[j5 + k4 * 32] = selection_color;
                            }
                            else if (k4 > 0 && DrawingArea.pixels[j5 + (k4 - 1) * 32] == 1)
                            {
                                DrawingArea.pixels[j5 + k4 * 32] = selection_color;
                            }
                            else if (j5 < 31 && DrawingArea.pixels[j5 + 1 + k4 * 32] == 1)
                            {
                                DrawingArea.pixels[j5 + k4 * 32] = selection_color;
                            }
                            else if (k4 < 31 && DrawingArea.pixels[j5 + (k4 + 1) * 32] == 1)
                            {
                                DrawingArea.pixels[j5 + k4 * 32] = selection_color;
                            }
                        }
                    }
                }
            }
            else if (selection_color == 0)             //shadow
            {
                for (int k5 = 31; k5 >= 0; k5--)
                {
                    for (int l4 = 31; l4 >= 0; l4--)
                    {
                        if (DrawingArea.pixels[k5 + l4 * 32] == 0 && k5 > 0 && l4 > 0 && DrawingArea.pixels[(k5 - 1) + (l4 - 1) * 32] > 0)
                        {
                            DrawingArea.pixels[k5 + l4 * 32] = 0x302020;
                        }
                    }
                }
            }
            if (itemDef.NotedModelItemID != -1)
            {
                int l5 = sprite.WholeWidth;
                int j6 = sprite.WholeHeight;
                sprite.WholeWidth  = 32;
                sprite.WholeHeight = 32;
                DrawingArea.DrawRSImage(sprite, 0, 0);
                sprite.WholeWidth  = l5;
                sprite.WholeHeight = j6;
            }
            sprite2.SetPixels(DrawingArea.pixels);
            DrawingArea.initDrawingArea(j2, i2, ai1);
            DrawingArea.setDrawingArea(j3, k2, l2, i3);
            Rasterizer.center_x             = k1;
            Rasterizer.center_y             = l1;
            Rasterizer.line_pixel_locations = ai;
            Rasterizer.aBoolean1464         = true;
            if (itemDef.Stackable)
            {
                sprite2.WholeWidth = 33;
            }
            else
            {
                sprite2.WholeWidth = 32;
            }
            sprite2.WholeHeight = amount;
            return(sprite2);
        }
Exemplo n.º 6
0
        public static RSImage GetModelSprite(int id, int amount, int selection_color)
        {
            Color k_color = Color.FromArgb(selection_color);
            ItemDefinition itemDef = GetItem(id);
            if (itemDef.StackedItemIDs == null)
                amount = -1;
            if (amount > 1)
            {
                int i1 = -1;
                for (int j1 = 0; j1 < 10; j1++)
                    if (amount >= itemDef.StackChangeAmounts[j1] && itemDef.StackChangeAmounts[j1] != 0)
                        i1 = itemDef.StackedItemIDs[j1];

                if (i1 != -1)
                    itemDef = GetItem(i1);
            }
            Model model = itemDef.GetModel(1);
            if (model == null)
                return null;
            RSImage sprite = null;
            if (itemDef.NotedModelItemID != -1)
            {
                sprite = GetModelSprite(itemDef.NotedID, 10, -1);
                if (sprite == null)
                    return null;
            }
            RSImage sprite2 = new RSImage(32, 32);
            int k1 = Rasterizer.center_x;
            int l1 = Rasterizer.center_y;
            int[] ai = Rasterizer.line_pixel_locations;
            int[] ai1 = DrawingArea.pixels;
            int i2 = DrawingArea.width;
            int j2 = DrawingArea.height;
            int k2 = DrawingArea.topX;
            int l2 = DrawingArea.bottomX;
            int i3 = DrawingArea.topY;
            int j3 = DrawingArea.bottomY;
            Rasterizer.aBoolean1464 = false;
            DrawingArea.initDrawingArea(32, 32, new int[32 * 32]);
            DrawingArea.method336(32, 0, 0, 0, 32);
            Rasterizer.method364();
            int k3 = itemDef.Zoom;
            if (selection_color == -1)
                k3 = (int)((double)k3 * 1.5D);
            if (selection_color > 0)
                k3 = (int)((double)k3 * 1.04D);
            int l3 = Rasterizer.SIN[itemDef.RotationX] * k3 >> 16;
            int i4 = Rasterizer.COS[itemDef.RotationX] * k3 >> 16;
            model.Render(itemDef.RotationY, itemDef.RotationZ, itemDef.RotationX, itemDef.SpriteX, l3 + model.modelHeight / 2 + itemDef.SpriteY, i4 + itemDef.SpriteY);

            //draw the black outline
            for (int i5 = 31; i5 >= 0; i5--)
            {
                for (int j4 = 31; j4 >= 0; j4--)
                {
                    if (DrawingArea.pixels[i5 + j4 * 32] == 0)
                    {
                        if (i5 > 0 && DrawingArea.pixels[(i5 - 1) + j4 * 32] > 1)
                            DrawingArea.pixels[i5 + j4 * 32] = 1;
                        else if (j4 > 0 && DrawingArea.pixels[i5 + (j4 - 1) * 32] > 1)
                            DrawingArea.pixels[i5 + j4 * 32] = 1;
                        else if (i5 < 31 && DrawingArea.pixels[i5 + 1 + j4 * 32] > 1)
                            DrawingArea.pixels[i5 + j4 * 32] = 1;
                        else if (j4 < 31 && DrawingArea.pixels[i5 + (j4 + 1) * 32] > 1)
                            DrawingArea.pixels[i5 + j4 * 32] = 1;
                    }
                }
            }

            //draw the selection outline or shadow
            if (selection_color > 0) //selection outline
            {
                for (int j5 = 31; j5 >= 0; j5--)
                {
                    for (int k4 = 31; k4 >= 0; k4--)
                    {
                        if (DrawingArea.pixels[j5 + k4 * 32] == 0)
                        {
                            if (j5 > 0 && DrawingArea.pixels[(j5 - 1) + k4 * 32] == 1)
                                DrawingArea.pixels[j5 + k4 * 32] = selection_color;
                            else if (k4 > 0 && DrawingArea.pixels[j5 + (k4 - 1) * 32] == 1)
                                DrawingArea.pixels[j5 + k4 * 32] = selection_color;
                            else if (j5 < 31 && DrawingArea.pixels[j5 + 1 + k4 * 32] == 1)
                                DrawingArea.pixels[j5 + k4 * 32] = selection_color;
                            else if (k4 < 31 && DrawingArea.pixels[j5 + (k4 + 1) * 32] == 1)
                                DrawingArea.pixels[j5 + k4 * 32] = selection_color;
                        }
                    }
                }

            }
            else if (selection_color == 0) //shadow
            {
                for (int k5 = 31; k5 >= 0; k5--)
                {
                    for (int l4 = 31; l4 >= 0; l4--)
                    {
                        if (DrawingArea.pixels[k5 + l4 * 32] == 0 && k5 > 0 && l4 > 0 && DrawingArea.pixels[(k5 - 1) + (l4 - 1) * 32] > 0)
                            DrawingArea.pixels[k5 + l4 * 32] = 0x302020;
                    }

                }

            }
            if (itemDef.NotedModelItemID != -1)
            {
                int l5 = sprite.WholeWidth;
                int j6 = sprite.WholeHeight;
                sprite.WholeWidth = 32;
                sprite.WholeHeight = 32;
                DrawingArea.DrawRSImage(sprite, 0, 0);
                sprite.WholeWidth = l5;
                sprite.WholeHeight = j6;
            }
            sprite2.SetPixels(DrawingArea.pixels);
            DrawingArea.initDrawingArea(j2, i2, ai1);
            DrawingArea.setDrawingArea(j3, k2, l2, i3);
            Rasterizer.center_x = k1;
            Rasterizer.center_y = l1;
            Rasterizer.line_pixel_locations = ai;
            Rasterizer.aBoolean1464 = true;
            if (itemDef.Stackable)
                sprite2.WholeWidth = 33;
            else
                sprite2.WholeWidth = 32;
            sprite2.WholeHeight = amount;
            return sprite2;
        }