Ejemplo n.º 1
0
        public void Hook(TextureHookInfo textureInfo)
        {
            Bitmap OutBitmap = null;

            if (TexMap.ContainsKey(textureInfo.TextureCacheKey.TextureHash))
            {
                OutBitmap = new Bitmap(Image.FromFile(TexMap[textureInfo.TextureCacheKey.TextureHash]));
            }
            else
            {
                if (PspStoredConfig.ScaleTextures)
                {
                    var inBitmap =
                        new Bitmap(textureInfo.Width, textureInfo.Height).SetChannelsDataInterleaved(
                            textureInfo.Data.CastToStructArray <OutputPixel, byte>(), BitmapChannelList.Rgba);
                    OutBitmap =
                        new Engine(new ColorAlphaLerp(), new ColorAlphaThreshold(32, 32, 32, 32)).Process(inBitmap);
                }
            }

            if (OutBitmap != null)
            {
                textureInfo.Data = OutBitmap.GetChannelsDataInterleaved(BitmapChannelList.Rgba)
                                   .CastToStructArray <byte, OutputPixel>();
                textureInfo.Width  = OutBitmap.Width;
                textureInfo.Height = OutBitmap.Height;
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var    Item     = (TextureElement)TextureList.SelectedItem;
            var    InBitmap = (Bitmap)TextureView.Image;
            Bitmap OutBitmap;

            if (false)
            {
                var OutImage = new cImage(InBitmap.Width * 2, InBitmap.Height * 2);
                libXBR.Xbr2X(cImage.FromBitmap(InBitmap), 0, 0, OutImage, 0, 0, true);
                OutBitmap = OutImage.ToBitmap();
            }
            else
            {
                OutBitmap =
                    (new Engine(new ColorAlphaLerp(), new ColorAlphaThreshold(32, 32, 32, 32))).Process(InBitmap);
            }
            Item.TextureOpengl.SetData(
                OutBitmap.GetChannelsDataInterleaved(BitmapChannelList.Rgba).CastToStructArray <OutputPixel>(),
                OutBitmap.Width, OutBitmap.Height);
            UpdateTexture();
            TextureList.Focus();
        }
Ejemplo n.º 3
0
            public async void DownloadImageAsync(string url, int?maxWidth, int?maxHeight, Action <BitmapType> callbackOnUiThread, OutBitmap outCachedResult = null)
            {
                Contract.Requires(!String.IsNullOrEmpty(url));

                CacheFile  file;
                CacheValue value;

                lock (this) {
                    if (!cachedFiles.TryGetValue(url, out file))
                    {
                        file = new CacheFile(url, this.CachePath);

                        cachedFiles [url] = file;
                    }
                    else
                    {
                        Logger.Trace("Cached file is already present, url={0}", url);
                    }

                    // create a custom bitmap loader key
                    CacheKey key = new CacheKey(url, maxWidth == null ? -1 : (int)maxWidth, maxHeight == null ? -1 : (int)maxHeight);

                    if (!cachedBitmaps.TryGetValue(key, out value))
                    {
                        value = new CacheValue(key);

                        cachedBitmaps [key] = value;
                    }
                    else
                    {
                        Logger.Trace("Cached bitmap key is already present, url={0}", url);

                        BitmapType existingBitmap = value.Bitmap;
                        if (null != existingBitmap)
                        {
                            if (null != outCachedResult)
                            {
                                Logger.Trace("Cached bitmap shortcircuited result, url={0}", url);

                                outCachedResult.Bitmap = existingBitmap;
                                return;
                            }
                        }
                    }

                    file.AddToNotifyList(value);
                    value.NotifyOnceReady(callbackOnUiThread);
                }

                await file.Download(HandleDownloaded);
            }