private void ShowFrameInfo(FrameEntry tag) { StringBuilder stringBuilder = new StringBuilder(); //stringBuilder.Append(string.Concat("Frames per Angle:", this.m_FrameCount[] / 5, "\n\n")); stringBuilder.Append(string.Concat("Length: ", this.m_Length, "\n\n")); stringBuilder.Append(string.Concat("Version: ", this.m_Version, "\n")); stringBuilder.Append(string.Concat("ColourCount: ", this.m_ColorCount, "\n")); stringBuilder.Append(string.Concat("ColourOffset: ", this.m_ColorAddress, "\n")); stringBuilder.Append(string.Concat("FramesCount: ", this.m_FrameCount, "\n")); stringBuilder.Append(string.Concat("FramesOffset: ", this.m_FrameAddress, "\n\n")); object[] mInitCoordsX = { "MainInitX: ", this.m_InitCoordsX, "\tMainInitY: ", this.m_InitCoordsY, "\nMainEndX: ", this.m_EndCoordsX, "\tMainEndY: ", this.m_EndCoordsY, "\n\n" }; stringBuilder.Append(string.Concat(mInitCoordsX)); object[] initCoordsX = { "Initial X:\t", tag.InitCoordsX, " End X:\t", tag.EndCoordsX, "\n" }; stringBuilder.Append(string.Concat(initCoordsX)); object[] initCoordsY = { "Initial Y:", tag.InitCoordsY, " End Y:\t", tag.EndCoordsY, "\n" }; stringBuilder.Append(string.Concat(initCoordsY)); object[] frameAndID = { "Frame:", tag.Frame, " ID:\t", tag.ID, "\n" }; stringBuilder.Append(string.Concat(frameAndID)); object[] objArray = { "\nWidth: ", tag.Width, " Height: ", tag.Height }; stringBuilder.Append(string.Concat(objArray)); stringBuilder.Append(string.Concat("\n\nSize: ", tag.Width * tag.Height)); this.infoBox.Text = string.Concat(stringBuilder.ToString(), "\nOffset: ", tag.DataOffset); }
//TODO: Save the image together with the background for the Gump //TODO: Make it so it's possible to open a entire folder full of subfolders inside //TODO: Export to .vd directly private void ChangeFrame(TreeNode childNode, TreeNode parentNode) { var c = int.Parse(parentNode.Tag.ToString()); this.colorTableBox.Image = CreateColorBarBitmap(c); var backgroundImgWidth = Math.Abs(this.m_EndCoordsX[c] - this.m_InitCoordsX[c]); var backgroundImgHeight = Math.Abs(this.m_EndCoordsY[c] - this.m_InitCoordsY[c]); this.treeFramesBox.SelectedNode = childNode; FrameEntry currentFrame = (FrameEntry)childNode.Tag; Bitmap frameImage = this.LoadFrameImage(currentFrame, c); Bitmap backgroundImage = new Bitmap(backgroundImgWidth, backgroundImgHeight); //Draws the background based on the offset provided by the data for (int x = 0; x < backgroundImgWidth; x++) { for (int y = 0; y < backgroundImgHeight; y++) { backgroundImage.SetPixel(x, y, Color.Black); } } //Expands the frame if the image can't fit if (this.mainImageBox.Size.Width < backgroundImgWidth || this.mainImageBox.Size.Height < backgroundImgHeight) { Size size = base.Size; int width = size.Width + (backgroundImgWidth - this.mainImageBox.Width); Size size1 = base.Size; base.Size = new Size(width, size1.Height + (backgroundImgHeight - this.mainImageBox.Height)); RichTextBox txtInfo = this.infoBox; Point location = this.infoBox.Location; int x = location.X + (backgroundImgWidth - this.mainImageBox.Width); Point point = this.infoBox.Location; txtInfo.Location = new Point(x, point.Y); this.mainImageBox.Size = new Size(backgroundImgWidth, backgroundImgHeight); } //TODO:Make this a unique method that takes a background image bmp and returns a new bitmap with both combined //Draws the frame on top of the background image for (var x = 0; x < frameImage.Width; x++) { for (var y = 0; y < frameImage.Height; y++) { var i = Math.Abs(this.m_InitCoordsX[c] - currentFrame.InitCoordsX); var j = Math.Abs(this.m_InitCoordsY[c] - currentFrame.InitCoordsY); var pixel = frameImage.GetPixel(x, y); backgroundImage.SetPixel(i + x, j + y, pixel); } } this.mainImageBox.BackgroundImageLayout = ImageLayout.Center; this.mainImageBox.BackgroundImage = backgroundImage; ShowFrameInfo(currentFrame); }
private bool ReadFrames(BinaryReader reader, int c) { reader.BaseStream.Seek(this.m_FrameAddress[c], SeekOrigin.Begin); //this.m_Frames[c].Clear(); for (var i = 0; i < this.m_FrameCount[c]; i++) { FrameEntry frameEntry = new FrameEntry(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadInt16(), reader.ReadInt16(), reader.ReadInt16(), reader.ReadInt16(), (uint)(this.m_FrameAddress[c] + (i * 16) + reader.ReadUInt32()), this.m_ColorCount[c]); if (m_Frames.ContainsKey(c)) { m_Frames[c].Add(frameEntry); } else { m_Frames[c] = new List <FrameEntry> { frameEntry }; } } return(true); }
//Inner image frame public Bitmap LoadFrameImage(FrameEntry currentFrameEntry, int c) { int x; int y; byte[] numArray = this._ImageData[c]; var frameWidth = Math.Abs(currentFrameEntry.EndCoordsX - currentFrameEntry.InitCoordsX); var frameHeight = Math.Abs(currentFrameEntry.EndCoordsY - currentFrameEntry.InitCoordsY); var frameImage = new Bitmap(frameWidth, frameHeight); //Changes the alpha of the image and the background pixels to a color that will be combined later for (x = 0; x < frameWidth; x++) { for (y = 0; y < frameHeight; y++) { var color = Color.White; frameImage.SetPixel(x, y, color); } } //Zero the counters x = 0; y = 0; //The address where the data with the pixels starts and ends var dataOffset = (int)(currentFrameEntry.DataOffset - this._ImageDataOffset[c]); //Draws the pixels based on the stored data while (y < frameHeight) { var num3 = dataOffset; dataOffset = num3 + 1;//Start of the drawing, offset + 1 byte k = numArray[num3]; if (k >= 128) { Color pixel; Color color; byte byte_; var num4 = dataOffset; dataOffset = num4 + 1; var num5 = numArray[num4]; var num6 = num5 / 16; var num7 = num5 % 16; if (num6 > 0) { var num8 = dataOffset; dataOffset = num8 + 1; byte_ = numArray[num8]; pixel = this.m_Colors[c][byte_].Pixel; color = frameImage.GetPixel(x, y); pixel = this.CombineColors(pixel, color, num6); frameImage.SetPixel(x, y, pixel); this.NextCoordinate(ref x, ref y, frameWidth, frameHeight); } for (k = (byte)(k - 128); k > 0; k = (byte)(k - 1)) { var num9 = dataOffset; dataOffset = num9 + 1; byte_ = numArray[num9]; pixel = this.m_Colors[c][byte_].Pixel; frameImage.SetPixel(x, y, pixel); this.NextCoordinate(ref x, ref y, frameWidth, frameHeight); } if (num7 <= 0) { continue; } var num10 = dataOffset; dataOffset = num10 + 1; byte_ = numArray[num10]; pixel = this.m_Colors[c][byte_].Pixel; color = frameImage.GetPixel(x, y); pixel = this.CombineColors(pixel, color, num7); frameImage.SetPixel(x, y, pixel); this.NextCoordinate(ref x, ref y, frameWidth, frameHeight); } else { while (k > 0) { this.NextCoordinate(ref x, ref y, frameWidth, frameHeight); k = (byte)(k - 1); } } } return(frameImage); }