Beispiel #1
0
        public void BuildArchive(string arcPath, string workingPath)
        {
            global::System.IO.MemoryStream memoryStream = new global::System.IO.MemoryStream();
            global::System.Collections.Generic.List <ARC_Studio.Workers.ARC.ArcEntry> list = new global::System.Collections.Generic.List <ARC_Studio.Workers.ARC.ArcEntry>();
            global::System.Collections.Generic.List <string> list2 = this.method_4(workingPath);
            foreach (string text in list2)
            {
                byte[] array = global::ARC_Studio.Workers.ARC.FileUtils.smethod_0(text);
                int    size  = array.Length;
                int    pos   = (int)memoryStream.Position;
                string name  = text.Substring(workingPath.Length);
                memoryStream.Write(array, 0, array.Length);
                ARC_Studio.Workers.ARC.ArcEntry item = new ARC_Studio.Workers.ARC.ArcEntry(name, size, pos);
                list.Add(item);
            }
            global::System.IO.MemoryStream memoryStream2 = this.method_3(list);
            int num = (int)memoryStream2.Length;

            foreach (ARC_Studio.Workers.ARC.ArcEntry arcEntry in list)
            {
                arcEntry.Pos += num;
            }
            memoryStream2 = this.method_3(list);
            this.method_2(arcPath, memoryStream2, memoryStream);
        }
Beispiel #2
0
 internal void method_12(string string_0, global::System.IO.MemoryStream memoryStream_0)
 {
     global::System.Text.Encoding utf = global::System.Text.Encoding.UTF8;
     byte[] bytes = utf.GetBytes(string_0);
     this.method_9((short)bytes.Length, memoryStream_0);
     memoryStream_0.Write(bytes, 0, bytes.Length);
 }
Beispiel #3
0
 private byte[] method_0(LanguagesContainer languagesContainer_0)
 {
     global::System.IO.MemoryStream memoryStream  = new global::System.IO.MemoryStream();
     global::System.IO.MemoryStream memoryStream2 = new global::System.IO.MemoryStream();
     foreach (LanguageEntry languageEntry in languagesContainer_0.Languages.Values)
     {
         byte[] array = this.method_1(languageEntry);
         this.class47_0.method_12(languageEntry.Name, memoryStream);
         this.class47_0.method_10(array.Length, memoryStream);
         memoryStream2.Write(array, 0, array.Length);
     }
     global::System.IO.MemoryStream memoryStream3 = new global::System.IO.MemoryStream();
     byte[] array2 = memoryStream.ToArray();
     memoryStream3.Write(array2, 0, array2.Length);
     array2 = memoryStream2.ToArray();
     memoryStream3.Write(array2, 0, array2.Length);
     return(memoryStream3.ToArray());
 }
        /// <summary>
        /// Returns a surface with the specified image rendered to it as characters.
        /// </summary>
        /// <param name="image">The image to render.</param>
        /// <returns>The surface.</returns>
        public TextSurface GetSurface(Texture2D image)
        {
            editor.Clear();

#if SFML
            using (var imageData = image.CopyToImage())
            {
                using (var memStream = new global::System.IO.MemoryStream())
                {
                    var binForm = new global::System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    memStream.Write(imageData.Pixels, 0, imageData.Pixels.Length);
                    memStream.Seek(0, global::System.IO.SeekOrigin.Begin);
                    pixels = (Color[])binForm.Deserialize(memStream);
                }
            }
#elif MONOGAME
            image.GetData <Color>(pixels);
#endif

            System.Threading.Tasks.Parallel.For(0, surface.Width * surface.Height, (i) =>
                                                //for (int i = 0; i < surface.Width * surface.Height; i++)
            {
                int allR = 0;
                int allG = 0;
                int allB = 0;

                int min = i * fontPixels;
                int max = min + fontPixels;

                for (int pixel = min; pixel < max; pixel++)
                {
                    Color color = pixels[indexes[pixel]];

                    allR += color.R;
                    allG += color.G;
                    allB += color.B;
                }

                // print our character
                byte sr = (byte)(allR / fontPixels);
                byte sg = (byte)(allG / fontPixels);
                byte sb = (byte)(allB / fontPixels);

                var newColor = new Color(sr, sg, sb);
                float sbri   = newColor.GetBrightness() * 255;


                Point surfacePoint = surface.GetPointFromIndex(i);
                if (UseBlockMode)
                {
                    if (sbri > 204)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 219, newColor); //█
                    }
                    else if (sbri > 152)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 178, newColor); //▓
                    }
                    else if (sbri > 100)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 177, newColor); //▒
                    }
                    else if (sbri > 48)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 176, newColor); //░
                    }
                    else
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 0, Color.Black);
                    }
                }
                else
                {
                    if (sbri > 230)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'#', newColor);
                    }
                    else if (sbri > 207)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'&', newColor);
                    }
                    else if (sbri > 184)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'$', newColor);
                    }
                    else if (sbri > 161)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'X', newColor);
                    }
                    else if (sbri > 138)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'x', newColor);
                    }
                    else if (sbri > 115)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'=', newColor);
                    }
                    else if (sbri > 92)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'+', newColor);
                    }
                    else if (sbri > 69)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)';', newColor);
                    }
                    else if (sbri > 46)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)':', newColor);
                    }
                    else if (sbri > 23)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'.', newColor);
                    }
                    else
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 0, Color.Black);
                    }
                }
            }
                                                );

            return(surface);
        }