Exemplo n.º 1
0
 public OutData(CombineImagePlane.ImageInfo lImage, string pExtension,
     int pWidth, int pHeight)
 {
     width = pWidth;
     height = pHeight;
     imageInfo = lImage;
     //if (!Mathf.IsPowerOfTwo(lImage.width)
     //    || !Mathf.IsPowerOfTwo(lImage.height))
     //{
     //    TextureScale.Point(lImage,
     //        Mathf.NextPowerOfTwo(lImage.width), Mathf.NextPowerOfTwo(lImage.height));
     //}
     //resource =GameResourceManager.Main.createImage(lImage);
     //resource.extension = pExtension;
 }
Exemplo n.º 2
0
    void readImage(string pPath)
    {
        FileInfo lFileInfo = new FileInfo(pPath);
        if (imgPathToData.ContainsKey(lFileInfo.ToString()))
        {
            nowOutData = imgPathToData[lFileInfo.ToString()];
        }
        else
        {
            var lExtension = System.IO.Path.GetExtension(fileBrowserDialog.selectedLocation);
            lExtension = lExtension.Substring(1, lExtension.Length - 1);
            //{
            int lXCount;
                var lImageFile = System.Drawing.Image.FromFile(fileBrowserDialog.selectedLocation);
                int lWidth = lImageFile.Width;
                int lHeight = lImageFile.Height;
                var lImageInfo = new CombineImagePlane.ImageInfo();
                //if (lWidth > maxSize || lHeight > maxSize)
                //{
                    print("decomposeImage(lImageFile)");
                    lImageInfo.rightBottomRect = decomposeImage(lImageFile, PixelFormat.Format32bppArgb,
                        out decomposedImages, out lXCount);
                    //lImageFile.Dispose();
                    //return;
                //}
                lImageFile.Dispose();
                lImageInfo.images = new RenderMaterialResourceInfo[decomposedImages.Length];
                lImageInfo.xCount = lXCount;
                int i = 0;
                foreach (var lDecomposedImage in decomposedImages)
                {
                    var lResource = GameResourceManager.Main.createImage(lDecomposedImage);
                    lResource.extension = lExtension;
                    lImageInfo.images[i] = lResource;
                    ++i;
                }

            //}
            //Texture2D lImage = new Texture2D(4, 4, TextureFormat.ARGB32, false);

            //using (var lImageFile = new FileStream(fileBrowserDialog.selectedLocation, FileMode.Open))
            //{
            //    BinaryReader lBinaryReader = new BinaryReader(lImageFile);
            //    lImage.LoadImage(lBinaryReader.ReadBytes((int)lImageFile.Length));
                //}
                nowOutData = new OutData(lImageInfo, lExtension, lWidth, lHeight);
            imgPathToData[lFileInfo.ToString()] = nowOutData;

        }
        foreach (var lRenderer in previewRenderer.GetComponentsInChildren<Renderer>())
        {
            lRenderer.enabled = false;
        }
        previewRenderer.GetComponent<CombineImagePlane>().imageInfo = nowOutData.imageInfo;

        Vector2 lSize = zzSceneImageGUI.getFitSize(drawMaxSize, nowOutData.width, nowOutData.height);
        previewTransform.localScale = new Vector3(lSize.x, lSize.y, 1f);
        sizeChangedEvent(nowOutData.width, nowOutData.height);
        //image = nowOutData.resource.resource;
        readImageEvent();
    }