Ejemplo n.º 1
0
        public static bool imagesetstyle(PhpResource im, PhpArray styles)
        {
            PhpGdImageResource img = PhpGdImageResource.ValidImage(im);
            if (img == null)
                return false;
            
            if (styles == null || styles.IsEmpty())
            {
                return false;
            }

            Bitmap brushImage = new Bitmap(styles.Count, 1);

            int i = 0;
            foreach (int value in styles.Values)
            {
                brushImage.SetPixel(i, 0, PHPColorToNETColor(value));
                i++;
            }

            img.styled = new TextureBrush(brushImage);

            return true;
        }
Ejemplo n.º 2
0
		public static int Select(ref PhpArray read, ref PhpArray write, ref PhpArray except, int tv_sec, int tv_usec)
		{
			if ((read == null || read.IsEmpty()) && (write == null || write.IsEmpty()))
				return except == null ? 0 : except.Count;

			var readResult = new PhpArray();
			var writeResult = new PhpArray();
			var i = 0;
			var timer = Stopwatch.StartNew();
			var waitTime = tv_sec*1000 + tv_usec;
			while (true)
			{
				if (read != null)
				{
					readResult.Clear();
					foreach (var item in read)
					{
						var stream = item.Value as PhpStream;
						if (stream == null)
							continue;
						if (stream.CanReadWithoutLock())
							readResult.Add(item.Key, item.Value);
					}
				}
				if (write != null)
				{
					writeResult.Clear();
					foreach (var item in write)
					{
						var stream = item.Value as PhpStream;
						if (stream == null)
							continue;
						if (stream.CanWriteWithoutLock())
							writeResult.Add(item.Key, item.Value);
					}
				}
				if (readResult.Count > 0 || writeResult.Count > 0 || except.Count > 0)
					break;
				i++;
				if (timer.ElapsedMilliseconds > waitTime)
					break;
				if (i < 10)
					Thread.Yield();
				else
					Thread.Sleep(Math.Min(i, waitTime));
			}
			read = readResult;
			write = writeResult;
			return read.Count + write.Count + (except == null ? 0 : except.Count);
		}