public Matrix(int height, int width) { Height = height; Width = width; Pixels = new Pixel[height, width]; }
public RawImage( int zoom, Rectangle bounds, Pixel[,] memory ) { this.zoom = zoom; this.bounds = bounds; if ( memory.GetLength(0) != bounds.Width || memory.GetLength(1) != bounds.Height ) throw new ArgumentOutOfRangeException( "memory" ); this.memory = memory; }
public override bool OnUserCreate() { _controller = new ImGuiController(ScreenWidth(), ScreenHeight(), this); velocity = new vf2d(0, 0); offset = new vf2d(0, 0); map = new Pixel[mapWidth, mapHeight]; intMap = new int[mapWidth, mapHeight]; Random rng = new Random(); for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { map[x, y] = new Pixel(x / (float)mapWidth, y / (float)mapHeight, 1f - (y / (float)mapHeight), 1f); intMap[x, y] = rng.Next(20); } } spr = new Sprite(0, 0); spr.LoadFromFile("assets/spritesheet03.png"); decal = new Decal(spr); mGameLayer = CreateLayer(); EnableLayer(mGameLayer, true); SetLayerCustomRenderFunction(mGameLayer, DrawImGui); return(true); }
public void SpawnPixelGrid(int x, int y) { gridX = x; gridY = y; pixels = new Pixel[gridX, gridY]; InitGrid(gridX, gridY); }
/* * Return list of fields indexed from 0. * Fields grab containg Pixels from patch. */ public override List <Field> GetFields(Pixel[,] patch) { int pixWidth = patch.GetLength(0) / width; int pixHeight = patch.GetLength(1) / height; List <Field> fields = new List <Field>(); int fieldIndex = 0; // select Field from matrix for (int fHeigth = 0; fHeigth < height; fHeigth++) { for (int fWidth = 0; fWidth < width; fWidth++) { var field = new Field(); field.Index = fieldIndex++; //Select Pixels from patch; int i = pixHeight * fHeigth; for (int pHeight = i; pHeight < i + pixHeight; pHeight++) { int e = pixWidth * fWidth; for (int pWidth = e; pWidth < e + pixWidth; pWidth++) { field.Pixels.Add(patch[pWidth, pHeight]); } } fields.Add(field); } } return(fields); }
public Form1() { InitializeComponent(); if (Tb_mapsize.TextLength != 0) _map_size = Convert.ToInt32(Tb_mapsize.Text); map_mass = new Pixel[_map_size, _map_size]; fill_mass(); }
//De même, méthode qui à l'inverse réduit les dimensions de l'image public void Reduction(int fact) { Console.WriteLine(); Pixel[,] image1 = new Pixel[haut / fact, large / fact]; for (int j = 0; j < this.haut / fact; j++) { for (int i = 0; i < this.large / fact; i++) { for (int ii = 0; ii < fact; ii++) { image1[j, i] = image[j * fact, i *fact]; } } } taille = (taille - 54) / (fact * fact) + 54; image = image1; haut /= fact; large /= fact; byte[] temp = Convertir_Int_To_Endian(large, 4); for (int i = 0; i < 4; i++) { header[18 + i] = temp[i]; } temp = Convertir_Int_To_Endian(haut, 4); for (int i = 0; i < 4; i++) { header[22 + i] = temp[i]; } temp = Convertir_Int_To_Endian(taille, 4); for (int i = 0; i < 4; i++) { header[2 + i] = temp[i]; } }
private double s = 0; // Superpixel Intervall Int #endregion Fields #region Constructors // =============== Konstruktor =============== public Superpixels(Image<Bgr, Byte> imageBgr, int superpixelCount) { // Werte setzen k = superpixelCount; n = imageBgr.Width * imageBgr.Height; s = Math.Sqrt((double)n / (double)k); area = Convert.ToInt32(2 * s * 2 * s); m = 12; // BGR to LAB Umrechnung und Vektormatrix erstellen imageLab = imageBgr.Convert<Lab, Byte>(); pixels = new Pixel[imageBgr.Width, imageBgr.Height]; for (int r = 0; r < imageLab.Height; r++) { for (int c = 0; c < imageLab.Width; c++) { double l = (double)imageLab.Data[r, c, 0] * 100 / 255; double a = (double)imageLab.Data[r, c, 1] - 128; double b = (double)imageLab.Data[r, c, 2] - 128; Bgr bgr = new Bgr(imageBgr.Data[r, c, 0], imageBgr.Data[r, c, 1], imageBgr.Data[r, c, 2]); pixels[c, r] = new Pixel(new Vector5(l, a, b, c, r), bgr); //Console.WriteLine("BGR = " + imageBgr.Data[r, c, 0] + " " + imageBgr.Data[r, c, 1] + " " + imageBgr.Data[r, c, 2]); //Console.WriteLine("RGB = " + imageBgr.Data[r, c, 2] + " " + imageBgr.Data[r, c, 1] + " " + imageBgr.Data[r, c, 0]); //Console.WriteLine("LAB = " + labValues[r, c].X + " " + labValues[r, c].Y + " " + labValues[r, c].Z); } } }
/// <summary> /// Cette méthode est très importante. Comme dit plus tôt, il faut que la largeur soit divisible par 4 pour que l'image puisse être lue. /// Dans le doute, on applique aussi ceci à la hauteur car nous n'avons pas trouvé d'informations claires à ce sujet. /// </summary> public void CorrectionTaillefichierdivisibilitépar4() { //on recompte la taille du fichier this.taillefichier = (this.hauteur * this.largeur) * 3 + 54; //il faut que largeur et hauteur soient divisible par 4 int hauteurarajouter = 0; if (this.hauteur % 4 != 0) { hauteurarajouter = 4 - (this.hauteur % 4); } int largeurarajouter = 0; if (this.largeur % 4 != 0) { largeurarajouter = 4 - (this.largeur % 4); } Pixel[,] matricetemp = new Pixel[this.hauteur + hauteurarajouter, this.largeur + largeurarajouter]; for (int i = 0; i < this.hauteur; i++) { for (int j = 0; j < this.largeur; j++) { matricetemp[i, j] = this.matricedepixels[i, j]; } } for (int i = 0; i < this.hauteur; i++) { for (int j = 0; j < largeurarajouter; j++) { matricetemp[i, this.largeur + j] = this.matricedepixels[i, this.largeur - 1]; } } for (int i = 0; i < this.largeur + largeurarajouter; i++) { for (int j = 0; j < hauteurarajouter; j++) { matricetemp[this.hauteur + j, i] = this.matricedepixels[this.hauteur - 1, i]; } } this.matricedepixels = new Pixel[this.hauteur + hauteurarajouter, this.largeur + largeurarajouter]; this.hauteur = this.hauteur + hauteurarajouter; this.largeur = this.largeur + largeurarajouter; for (int j = 0; j < this.largeur; j++) { for (int i = 0; i < this.hauteur; i++) { this.matricedepixels[i, j] = matricetemp[i, j]; } } }
/// <summary> /// Ce constructeur est utilisé pour lire des images /// </summary> /// <param name="fichier"></param> public MyImage(string fichier) { byte[] myfile = File.ReadAllBytes(fichier); this.tailleFichier = myfile.Length; ///taille de l'image en octet //c'est pas bon, bytes 2 à 5 this.tailleOffset = Convert_Endian_To_Int(myfile, 10, 13); ///peut etre 14 à 17 this.largeur = Convert_Endian_To_Int(myfile, 18, 21); ///Largeur de l'image en pixels this.hauteur = Convert_Endian_To_Int(myfile, 22, 25); ///hauteur de l'image en pixels this.nbBitCouleur = Convert_Endian_To_Int(myfile, 28, 29); ///Nombre de bits codant chaque couleur Pixel[,] matRGB = new Pixel[this.largeur, this.hauteur]; int index = 54; ///c'est l'index qui servira qui parcours le tableau "myfile" for (int i = 0; i < hauteur; i++) { for (int j = 0; j < largeur; j++) ///on utilise ici un double index pour parcourir toute la matrice { matRGB[j, i] = new Pixel(myfile[index], myfile[index + 1], myfile[index + 2]); ///l'index est la position de l'octet de la première couleur, et les "+1" et "+2" servent à acceder aux deux autres couleurs index += 3; ///on ajoute 3 pour acceder à la première couleur du prochain pixel } } this.image = matRGB; if (myfile[0] == 66 && myfile[1] == 77) ///si les lettres encodées sont "B" et "M" c'est un fichier bitmap { this.typeImage = ".bmp"; } }
public void BitMap(string name) { int adds, position; byte[] data = File.ReadAllBytes(name); OffBits = BitConverter.ToInt32(data, 10); HeaderInfo = new byte[OffBits]; Array.Copy(data, HeaderInfo, OffBits); BitCount = BitConverter.ToInt16(HeaderInfo, 28); Width = BitConverter.ToInt32(HeaderInfo, 18); Height = BitConverter.ToInt32(HeaderInfo, 22); Size = BitConverter.ToInt32(HeaderInfo, 2); Pixels = new Pixel[Height, Width]; adds = (4 - (Width * (BitCount / 8) % 4)) % 4; for (int x = 0; x < Height; x++) { for (int y = 0; y < Width; y++) { Pixels[x, y] = new Pixel(); position = OffBits + ((BitCount / 8) * Width + adds) * x + y * (BitCount / 8); Pixels[x, y].B = data[position]; Pixels[x, y].G = data[position + 1]; Pixels[x, y].R = data[position + 2]; } } }
/// <summary> /// Permet de faire une rotation de l'image dans un sens trigonométrique, en sachant que l'origine de l'image est en bas à gauche pour nous /// </summary> public void RotationSensTrigo() { Pixel[,] matricetournée = new Pixel[this.largeur, this.hauteur]; for (int j = 0; j < this.largeur; j++) { for (int i = 0; i < this.hauteur; i++) { matricetournée[j, this.hauteur - i - 1] = this.matricedepixels[i, j]; } } this.matricedepixels = null; this.matricedepixels = new Pixel[this.largeur, this.hauteur]; int a = this.hauteur; this.hauteur = this.largeur; this.largeur = a; for (int j = 0; j < this.largeur; j++) { for (int i = 0; i < this.hauteur; i++) { this.matricedepixels[i, j] = matricetournée[i, j]; } } }
/// <summary> /// Cette méthode permet de réduire l'image en largeur en fonction d'un coefficient entier /// ATTENTION : Pour qu'une image puisse être lue il faut que sa largeur soit divisible par 4, c'est pourquoi on applique une méthode de correction après /// </summary> /// <param name="coefficient"> /// Coefficient de rédution de l'image en largeur qui sera compris entre 1 et 10 dans le WPF /// </param> public void RetrecirImageLargeur(int coefficient) { int vraielargeur = this.largeur / coefficient; Pixel[,] matricereduite = new Pixel[this.hauteur, vraielargeur]; for (int hauteur = 0; hauteur < this.hauteur; hauteur++) { int k = 0; for (int u = 0; u < vraielargeur; u++) { Pixel[] tab = new Pixel[coefficient]; for (int i = 0; i < coefficient; i++) { tab[i] = this.matricedepixels[hauteur, k + i]; } matricereduite[hauteur, u] = Fusion(tab); k = k + coefficient; } } this.largeur = vraielargeur; this.matricedepixels = new Pixel[this.hauteur, this.largeur]; for (int j = 0; j < this.largeur; j++) { for (int i = 0; i < this.hauteur; i++) { this.matricedepixels[i, j] = matricereduite[i, j]; } } }
/// <summary> /// Cette méthode permet d'agrandir l'image en largeur en fonction d'un coefficient donné /// </summary> /// <param name="coefficient"> /// Coefficient d'agrandissement entier qui sera compris entre 1 et 10 dans le WPF /// </param> public void AgrandirImageHauteur(int coefficient) { Pixel[,] matriceagrandie = new Pixel[this.hauteur * coefficient, this.largeur]; for (int hauteur = 0; hauteur < this.hauteur; hauteur++) { for (int largeur = 0; largeur < this.largeur; largeur++) { int k = 0; while (k < coefficient) { matriceagrandie[hauteur * coefficient + k, largeur] = this.matricedepixels[hauteur, largeur]; k++; } } } this.matricedepixels = null; this.hauteur = this.hauteur * coefficient; this.matricedepixels = new Pixel[this.hauteur, this.largeur]; for (int i = 0; i < this.largeur; i++) { for (int j = 0; j < this.hauteur; j++) { this.matricedepixels[j, i] = matriceagrandie[j, i]; } } }
public void Recortar(int p, int pp, int ppp, int pppp, int r, int rr) { this.ancho = r; this.alto = rr; // LE AGREGAMOS UNA COPIA DE LOS PÍXELES DE LA IMAGEN ACTUAL Pixel[,] newDatos = new Pixel[r, rr]; int i = p; int k = 0; while (i < ppp && k < r) { int j = pp; int l = 0; while (j < pppp && l < rr) { newDatos[k, l] = new Pixel((byte)datos[i, j].GetR(), (byte)datos[i, j].GetG(), (byte)datos[i, j].GetB()); j++; l++; } i++; k++; } this.datos = newDatos; }
public byte[] GenerateCode(byte imgId, byte animType, byte speed, byte loops, byte nextanimImg) { Pixel[,] array = this.GetPixelArray(0); var imgCode = new List <byte> { imgId, animType, speed, loops, nextanimImg }; Boolean init = true; byte prevValue = 0; byte sameValIncrement = 0; for (int Xcount = 0; Xcount < array.GetLength(0); Xcount++) { for (int Ycount = 0; Ycount < array.GetLength(1); Ycount++) { if (init) { prevValue = array[Xcount, Ycount].GetPixelValue(); imgCode.Add(prevValue); init = false; } else { if (array[Xcount, Ycount].GetPixelValue() == prevValue) { if (sameValIncrement < 200) { sameValIncrement++; } else { imgCode.Add(sameValIncrement); sameValIncrement = 0; } } else { prevValue = array[Xcount, Ycount].GetPixelValue(); if (sameValIncrement == 0) { imgCode.Add(prevValue); } else { imgCode.Add(sameValIncrement); imgCode.Add(prevValue); sameValIncrement = 0; } } } } } return(imgCode.ToArray()); }
public static bool ParseAndExecute(ConsoleKeyInfo keyPressed) { if (GetFocusedSubProgram() != null) { GetFocusedSubProgram().ParseAndExecute(keyPressed); return(true); } /* * switch (keyPressed.Key) * { * case ConsoleKey.Escape: * FocusCursor.BackwardToLowerHierarchy(); * break; * case ConsoleKey.UpArrow: * FocusCursor.BackwardToLowerHierarchy(); * break; * * case ConsoleKey.Enter: * FocusCursor.ForwardToHigherHierarchy(); * break; * case ConsoleKey.DownArrow: * FocusCursor.ForwardToHigherHierarchy(); * break; * * case ConsoleKey.Tab: * FocusCursor.ToNextFocus(); * break; * case ConsoleKey.RightArrow: * FocusCursor.ToNextFocus(); * break; * * case ConsoleKey.LeftArrow: * FocusCursor.ToPreviousFocus(); * break; * * default: * GetFocusedSubProgram().ParseAndExecute(k); * break; * } */ SubProgram p = GetFocusedSubProgram(); Coordinates c = p.Window_Component.Anchor; Pixel[,] tempRenderBuffer = p.GetRenderBuffer(); for (int j = 0; j < Height; j++) { for (int i = 0; i < Width; i++) { Layers[p.ProgramID][i + c.X, j + c.Y] = tempRenderBuffer[i, j]; } } return(false); }
public Frame(int width, int height, PixelFormat pixelFormat) { _pixelFormat = pixelFormat; Width = width; Height = height; _pixels = new Pixel[width, height]; _pixelBytes = new byte[BytesPerPixel * Width * Height]; }
/// <summary> /// Creates a blank PixelMap of desired width and height.</summary> public PixelMap(int width, int height) { Width = width; Height = height; map = new Pixel[Width, Height]; BPP = 4; format = PixelFormat.Format32bppArgb; }
public Map(int width, int height) { _width = width < Game.WINDOW_WIDTH ? width : Game.WINDOW_WIDTH; _height = height < Game.WINDOW_HEIGHT ? height : Game.WINDOW_HEIGHT; _pixels = new Pixel[Height, Width]; _pixelsBoof = new Pixel[Height, Width]; InitilizationOfMap(); }
public PixelSet(int width, int height) { Width = width; Height = height; _pixel = new Pixel[Width, Height]; FillTransparent(); }
/// <summary> /// Initializes a new instance of the <see cref="GraphicBuffer"/> class. /// </summary> /// <param name="size">The size of the buffer.</param> public GraphicBuffer(Size size) { this.Size = size; this.buffer = new Pixel[this.Size.Width, this.Size.Height]; this.Clear(); }
public BitmapImage(int pixelWidth, int pixelHeight) { PixelWidth = pixelWidth; PixelHeight = pixelHeight; InitHeader(); _imageData = new Pixel[PixelHeight, PixelWidth]; }
/// <summary> /// Initializes a new instance of the <see cref="GraphicBuffer"/> class. /// </summary> /// <param name="size">The size of the buffer.</param> public GraphicBuffer(Size size) { this.Size = size; this.buffer = new Pixel[this.Size.Width, this.Size.Height]; this.Clear(); }
public Image(byte[] info, int width, int height, int fileSize, Pixel[,] pixels) { this.info = info; this.Width = width; this.Height = height; this.FileSize = fileSize; this.Pixels = pixels; }
public Photo(int width, int height) { Width = width; Height = height; _pixels = new Pixel[Width, Width]; InitializePixels(); }
/// <summary> /// sert à modifier la largeur et la hauteur d'un fichier bmp après y avoir fait des modifications /// </summary> /// <param name="picture"></param> correspond à la nouvelle matrice de pixel public void ChangerProprietees(Pixel[,] picture) { taille -= image.GetLength(0) * image.GetLength(1); largeur = picture.GetLength(1); hauteur = picture.GetLength(0); taille += largeur * hauteur * 9; image = picture; }
public PixelsSource(Pixel[,] pixels, List <Pixel> pixelsList) { this.Pixels = pixels; this.pixelsList = pixelsList; foreach (var siblingDirection in Enum.GetValues(typeof(SiblingDirection)).Cast <SiblingDirection>()) { this.siblingDirectionToVectorMap[(int)siblingDirection] = siblingDirection.ToVector(); } }
//public delegate Pixel[,] GetAppearanceDelegate(); //public GetAppearanceDelegate GetRenderBufferHandler; public Window(int width, int height) { Width = width; Height = height; RenderBuffer = new Pixel[width, height]; InteractiveUnitsCollection.Add(new TitleBar()); }
public Matrix(int height, int width, int realHeight, int realWidth) { Height = height; Width = width; RealHeight = realHeight; RealWidth = realWidth; Pixels = new Pixel[height, width]; }
public Image(Pixel[,] pixels) { if (pixels.GetLength(0) != Height || pixels.GetLength(1) != Width) { throw new ArgumentException(nameof(pixels)); } _pixels = pixels; }
public void ImageConstructorMaxRangeUnder0Test() { Pixel[,] pixels = { { new Pixel(111, 222, 222), new Pixel(123, 134, 115) }, { new Pixel(222, 123, 167), new Pixel(222, 123, 167) } }; Action action = delegate { new Image("ey", -1, pixels); }; Assert.ThrowsException <ArgumentException>(action); }
public void ImageConstructorNotFilledToCapTest() { Pixel[,] pixels = { { new Pixel(111, 222, 222), new Pixel(123, 134, 115) }, { null, new Pixel(222, 123, 167) } }; Action action = delegate { new Image("ey", 255, pixels); }; Assert.ThrowsException <ArgumentException>(action); }
public Tile(int height) { this.height = height; pixelMap = new Pixel[height, height]; free = true; full = false; push = true; fillMap(); }
public Scherm(int width, int height) { this.width = width; this.height = height; this.windowTitle = defaultWindowTitle; this.images = GetImages(); this.bannerImage = defaultBannerImage; this.window = populateWindow(); }
private LBVImage() { Width = 320; Height = 200; Bpp = 8; palette = new Pixel[256]; rawPixels = new byte[Width * Height]; realPixels = new Pixel[Width, Height]; }
/// <summary> /// Quickly creates a PixelMap from a Bitmap.</summary> /// <seealso cref="PixelMap.SlowLoad"> /// Copies a Bitmap through slow pixel-by-pixel reads. </seealso> public PixelMap(Bitmap b) { Width = b.Width; Height = b.Height; map = new Pixel[Width, Height]; format = b.PixelFormat; var data = b.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, format); switch (b.PixelFormat) { case PixelFormat.Format32bppArgb: case PixelFormat.Format32bppRgb: BPP = 4; break; case PixelFormat.Format24bppRgb: BPP = 3; break; default: throw new FormatException("PixelFormat cannot be loaded. Try PixelMap.SlowLoad instead."); } int bytes = Math.Abs(data.Stride) * b.Height; byte[] raw = new byte[bytes]; System.Runtime.InteropServices.Marshal.Copy(data.Scan0, raw, 0, bytes); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { int offset = (y * data.Width + x) * BPP; byte B = raw[offset]; offset++; byte G = raw[offset]; offset++; byte R = raw[offset]; byte A = 0; if (BPP == 4) { offset++; A = raw[offset]; } map[x, y] = new Pixel(A, R, G, B); } } b.UnlockBits(data); }
public void CreatePixels(int w, int h) { Pixel[,] pixels = new Pixel[w, h]; for(int y = 0; y < h; y++) for(int x = 0; x < w; x++) pixels[x, y] = new Pixel(x, y); if(_pixels != null) for(int y = 0; y < Math.Min(h, _shape.Height); y++) for(int x = 0; x < Math.Min(w, _shape.Width); x++) pixels[x, y] = _pixels[x, y]; _pixels = pixels; }
/// <summary> /// Clones a PixelMap.</summary> public PixelMap(PixelMap original) { Width = original.Width; Height = original.Height; map = new Pixel[Width, Height]; BPP = original.BPP; format = original.format; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { this[x, y] = original[x, y]; } } }
//public Image(int width, int height) //{ // _pixels = new Pixel[width, height]; // for (int x = 0; x < width; x++) // for (int y = 0; y < height; y++) // _pixels[x, y] = new Pixel(x, y); //} public Image(double width, double height, System.Drawing.Bitmap bitmap, Interpolators.IInterpolator interpolator) { if (interpolator == null) throw new ArgumentNullException("interpolator", "interpolator is null."); if (bitmap == null) throw new ArgumentNullException("bitmap", "bitmap is null."); if (Width < 0) throw new Exception("Width can't be negative"); if (Height < 0) throw new Exception("Height can't be negative"); Width = width; Height = height; _interpolator = interpolator; ScaleHorizontal = (bitmap.Width - 1) / Width; ScaleVertical = (bitmap.Height - 1) / Height; _pixels = new Pixel[bitmap.Width, bitmap.Height]; for (int x = 0; x < bitmap.Width; x++) for (int y = 0; y < bitmap.Height; y++) _pixels[x, y] = new Pixel(bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness(), x, y); }
private void ConvertToPixels() { int w = Bitmap.PixelWidth; int h = Bitmap.PixelHeight; int stride = Bitmap.BackBufferStride; int size = stride * h; Pixels = new Pixel[h,w]; Bitmap.Lock(); unsafe { var pixels = (byte*)Bitmap.BackBuffer; int i=0; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++, i += 4) { Pixels[y, x] = new Pixel(pixels[i+2],pixels[i+1],pixels[i]); } } } // Bitmap.AddDirtyRect(new Int32Rect(0, 0, w, h)); Bitmap.Unlock(); }
public ImageDecoder( RawImage target ) { memory = target.Memory; ClearBuffer(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void conn_OnMessage(object sender, Message e) { if (!ListenForPackets) return; if (OnPacket != null) { Packet packet = new Packet(e.Type); for (uint n = 0; n < e.Count; n++) { packet.Add(e[n]); } OnPacket(this, packet); } switch (e.Type) { case "init": WorldKey = Rot13(e.GetString(5)); if (OnWorldKey != null) OnWorldKey(this, WorldKey); MapData = Init2Array(e); if (OnInit != null) { User bot = new User(e.GetString(9), e.GetInt(6)); bot.Move.Position.X = (double)e.GetInt(7); bot.Move.Position.Y = (double)e.GetInt(8); Dictionary<int, int> potData = Init2Pot(e); OnInit(this, e.GetString(0), e.GetString(1), e.GetString(2), e.GetInt(3), e.GetInt(4), WorldKey, bot, e.GetBoolean(10), e.GetBoolean(11), e.GetInt(12), e.GetInt(13), e.GetBoolean(14), e.GetDouble(15), e.GetBoolean(16), MapData, potData); } break; case "info": if (OnInfo != null) OnInfo(this, e.GetString(0), e.GetString(1)); break; case "p": if (OnPotion != null) OnPotion(this, e.GetInt(0), e.GetInt(1), e.GetBoolean(2)); break; case "write": if (OnWrite != null) OnWrite(this, e.GetString(0), e.GetString(1)); break; case "upgrade": if (OnUpgrade != null) OnUpgrade(this); break; case "m": if (OnMove != null) { User.Motion motion = new User.Motion(); motion.Position.X = e.GetDouble(1); motion.Position.Y = e.GetDouble(2); motion.Velocity.X = e.GetDouble(3); motion.Velocity.Y = e.GetDouble(4); motion.Acceleration.X = e.GetDouble(5); motion.Acceleration.Y = e.GetDouble(6); motion.KeyDown.X = e.GetDouble(7); motion.KeyDown.Y = e.GetDouble(8); OnMove(this, e.GetInt(0), motion, e.GetInt(9), e.GetBoolean(10), e.GetBoolean(11)); } break; case "add": if (OnAdd != null || ListUsers) { User u = new User(e.GetString(1), e.GetInt(0)); u.SmileyID = e.GetInt(2); u.Move.Position.X = e.GetDouble(3); u.Move.Position.Y = e.GetDouble(4); u.isGod = e.GetBoolean(5); u.isMod = e.GetBoolean(6); u.isChat = e.GetBoolean(7); u.Coins = e.GetInt(8); u.isFriend = e.GetBoolean(9); u.isPurple = e.GetBoolean(10); u.Level = e.GetInt(11); u.isClubMember = e.GetBoolean(12); if (OnAdd != null) OnAdd(this, u); if (ListUsers) Manager.UserJoined(u); } break; case "c": if (OnCoin != null) OnCoin(this, e.GetInt(0), e.GetInt(1)); break; case "k": if (OnCrown != null) OnCrown(this, e.GetInt(0)); break; case "ks": if (OnWin != null) OnWin(this, e.GetInt(0)); break; case "b": if (OnBlock != null) OnBlock(this, e.GetInt(0), e.GetInt(1), e.GetInt(2), e.GetInt(3), e.GetInt(4), -1, -1, -1, -1, -1, ""); break; case "bc": if (OnBlock != null) OnBlock(this, 0, e.GetInt(0), e.GetInt(1), e.GetInt(2), -1, e.GetInt(3), -1, -1, -1, -1, ""); break; case "bs": if (OnBlock != null) OnBlock(this, 0, e.GetInt(0), e.GetInt(1), e.GetInt(2), -1, -1, e.GetInt(3), -1, -1, -1, ""); break; case "pt": if (OnBlock != null) OnBlock(this, 0, e.GetInt(0), e.GetInt(1), e.GetInt(2), -1, -1, -1, e.GetInt(3), e.GetInt(4), e.GetInt(5), ""); break; case "lb": if (OnBlock != null) OnBlock(this, 0, e.GetInt(0), e.GetInt(1), e.GetInt(2), -1, -1, -1, -1, -1, -1, e.GetString(3)); break; case "br": if (OnBlock != null) OnBlock(this, 0, e.GetInt(0), e.GetInt(1), e.GetInt(2), -1, -1, -1, e.GetInt(3), -1, -1, ""); break; case "show": if (OnShow != null) OnShow(this, e.GetString(0)); break; case "hide": if (OnHide != null) OnHide(this, e.GetString(0)); break; case "face": if (OnFace != null) OnFace(this, e.GetInt(0), e.GetInt(1)); break; case "god": if (OnGod != null) OnGod(this, e.GetInt(0), e.GetBoolean(1)); break; case "mod": if (OnMod != null) OnMod(this, e.GetInt(0)); break; case "lostaccess": if (OnLostAccess != null) OnLostAccess(this); break; case "access": if (OnAccess != null) OnAccess(this); break; case "allowpotions": if (OnAllowPotions != null) { List<int> potions = new List<int>(); for (uint n = 1; n < e.Count; n++) { potions.Add(e.GetInt(n)); } OnAllowPotions(this, e.GetBoolean(0), potions.ToArray()); } break; case "wu": if (OnWootUp != null) OnWootUp(this, e.GetInt(0)); break; case "w": if (OnWoot != null) OnWoot(this, e.GetInt(0)); break; case "levelup": if (OnLevelUp != null) OnLevelUp(this, e.GetInt(0), e.GetInt(1)); break; case "say": if (OnSay != null) OnSay(this, e.GetInt(0), e.GetString(1)); break; case "say_old": if (OnSayOld != null) OnSayOld(this, e.GetString(0), e.GetString(1)); break; case "updatemeta": if (OnUpdateMeta != null) OnUpdateMeta(this, e.GetString(0), e.GetString(1), e.GetInt(2), e.GetInt(3), e.GetInt(4)); break; case "autotext": if (OnQuickChat != null) OnQuickChat(this, e.GetInt(0), e.GetString(1)); break; case "left": if (OnLeft != null) OnLeft(this, e.GetInt(0)); if (ListUsers) Manager.UserLeft(e.GetInt(0)); break; case "clear": if (OnClear != null) OnClear(this, e.GetInt(0), e.GetInt(1)); break; case "tele": //owner reset level OR a user got killed if (OnReset != null) { List<SpawnInfo> si = new List<SpawnInfo>(); for (uint n = 1; n < e.Count; n += 3) { si.Add(new SpawnInfo(e.GetInt(n), e.GetInt(n + 1), e.GetInt(n + 2))); } OnReset(this, e.GetBoolean(0), si.ToArray()); } break; case "reset": // owner loded level MapData = Load2Array(e); if (OnLoadLevel != null) OnLoadLevel(this, MapData); break; case "saved": if (OnSave != null) OnSave(this); break; default: if (OnOther != null) { Packet packet = new Packet(e.Type); for (uint n = 0; n < e.Count; n++) { packet.Add(e[n]); } OnOther(this, packet); } break; } }
public Image(string name, int width, int height) { this.name = name; this.width = width; this.height = height; data = new Pixel[width, height]; //Initialise the three buffers such that the image would be pure black. for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { data[x, y] = new Pixel(0, 0, 4); } } }
/// <summary> /// Generates a distance texture from the alpha channel of a source texture. /// </summary> /// <param name="source"> /// Source texture. Alpha values of 1 are considered inside, values of 0 are considered outside, and any other values are considered /// to be on the edge. Must be readable. /// </param> /// <param name="destination"> /// Destination texture. Must be the same size as the source texture. Must be readable. /// The texture change does not get applied automatically, you need to do that yourself. /// </param> /// <param name="maxInside"> /// Maximum pixel distance measured inside the edge, resulting in an alpha value of 1. /// If set to or below 0, everything inside will have an alpha value of 1. /// </param> /// <param name="maxOutside"> /// Maximum pixel distance measured outside the edge, resulting in an alpha value of 0. /// If set to or below 0, everything outside will have an alpha value of 0. /// </param> /// <param name="postProcessDistance"> /// Pixel distance from the edge within which pixels will be post-processed using the edge gradient. /// </param> /// <param name="rgbMode"> /// How to fill the destination texture's RGB channels. /// </param> public static void Generate (Texture2D source, Texture2D destination, float maxInside, float maxOutside, float postProcessDistance, RGBMode rgbMode) { if(source.height != destination.height || source.width != destination.width){ Debug.LogError("Source and destination textures must be the same size."); return; } try{ source.GetPixel(0, 0); } catch{ Debug.LogError("Source texture is not read/write enabled."); return; } try{ destination.GetPixel(0, 0); } catch{ Debug.LogError("Destination texture is not read/write enabled."); return; } width = source.width; height = source.height; pixels = new Pixel[width, height]; int x, y; float scale; Color c = rgbMode == RGBMode.White ? Color.white : Color.black; for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ pixels[x, y] = new Pixel(); } } if(maxInside > 0f){ for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ pixels[x, y].alpha = 1f - source.GetPixel(x, y).a; } } ComputeEdgeGradients(); GenerateDistanceTransform(); if(postProcessDistance > 0f){ PostProcess(postProcessDistance); } scale = 1f / maxInside; for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ c.a = Mathf.Clamp01(pixels[x, y].distance * scale); destination.SetPixel(x, y, c); } } } if(maxOutside > 0f){ for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ pixels[x, y].alpha = source.GetPixel(x, y).a; } } ComputeEdgeGradients(); GenerateDistanceTransform(); if(postProcessDistance > 0f){ PostProcess(postProcessDistance); } scale = 1f / maxOutside; if(maxInside > 0f){ for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ c.a = 0.5f + (destination.GetPixel(x, y).a - Mathf.Clamp01(pixels[x, y].distance * scale)) * 0.5f; destination.SetPixel(x, y, c); } } } else{ for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ c.a = Mathf.Clamp01(1f - pixels[x, y].distance * scale); destination.SetPixel(x, y, c); } } } } if(rgbMode == RGBMode.Distance){ for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ c = destination.GetPixel(x, y); c.r = c.a; c.g = c.a; c.b = c.a; destination.SetPixel(x, y, c); } } } else if(rgbMode == RGBMode.Source){ for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ c = source.GetPixel(x, y); c.a = destination.GetPixel(x, y).a; destination.SetPixel(x, y, c); } } } pixels = null; }
// Loads the 1D array with pixels into a simple 2D array using Pixel containers. private void LoadArray(uint[] data) { _pixelData = new Pixel[_imageWidth, _imageHeight]; for (int i = 0, height = 0, width = 0; i < data.Length; ++i, ++width) { if (width == _imageWidth) { width = 0; height++; } // Create a pixel container: _pixelData[width, height] = new Pixel { X = (short)width, Y = (short)height, Color = data[i], TmpLabel = null }; } }
/// <summary> /// Constructor. /// </summary> public PixelMap() { _map = new Pixel[600,600]; }
private void chng_apply_Click(object sender, EventArgs e) { if(Isl_count.TextLength != 0 && Tw1.TextLength != 0 && Tw2.TextLength != 0 && Tw3.TextLength != 0 && Tw4.TextLength != 0 && Tw5.TextLength != 0 && Tw6.TextLength != 0 && Tw7.TextLength != 0 && Tw8.TextLength != 0) { if (Tb_mapsize.TextLength != 0) _map_size = Convert.ToInt32(Tb_mapsize.Text); map_mass = new Pixel[_map_size, _map_size]; fill_mass(); mass_existense = true; make_archipelago(); Map.Refresh(); } }
public RemoveLayerAction( ImageInfo image, int index, Layer layer ) : base(image) { myLayerIndex = index; myLabel = layer.Label; myPixels = (Pixel[,]) layer.Pixels.Clone(); }
public EditLayerAction( ImageInfo image, Layer layer ) : base(image) { myLayerIndex = image.Layers.IndexOf( layer ); myPixels = (Pixel[,]) layer.Pixels.Clone(); }
private void load_btt_Click(object sender, EventArgs e) { DialogResult res = ofd.ShowDialog(); if (res == DialogResult.OK) { using (StreamReader sr = new StreamReader(ofd.FileName)) { _map_size = VERNI_MOYE(sr.ReadLine()); map_mass = new Pixel[map_size, map_size]; fill_mass(); string s; int[] output = new int[3]; for (int y = 0; y < map_size; y++) { for (int x = 0; x < map_size; x++) { for (int i = 0; i < 3; i++) { s = sr.ReadLine(); output[i] = Convert.ToInt32(Regex.Replace(s, @"[^\d]+", "")); } boje_moy(output, x, y); } } } mass_existense = true; Map.Refresh(); } }