コード例 #1
0
ファイル: PhotoIO.cs プロジェクト: sevenli777/Sprayscape-VR
    public static void RegenerateThumbnailImage()
    {
        Debug.Log("RegenerateThumbnailImage");

        AllocateThumbnails();

        if (!prefsLoaded)
        {
            LoadFilePaths();
        }

        Texture2D     texture = new Texture2D(2048, 1024, TextureFormat.ARGB32, false);     // dummy texture so we can load into it
        RenderTexture rt      = RenderTexture.GetTemporary(2048, 1024);

        for (int i = 0; i < PhotoIO.saveMap.Count; i++)
        {
            PhotoIO.LoadImage(ref texture, PhotoIO.saveMap[i]);

            Graphics.Blit(texture, rt);
            PhotoIO.InsertThumbnail(rt, PhotoIO.saveMap [i]);
        }

        RenderTexture.ReleaseTemporary(rt);

        SaveThumbnailImage();
    }
コード例 #2
0
 public SavedSpray(int id, int order)
 {
     this.id        = id;
     this.order     = order;
     this.label     = PhotoIO.PhotoLabel(id);
     this.thumbnail = PhotoIO.thumbnails;
 }
コード例 #3
0
 public void LoadTexture()
 {
     if (texture == null)
     {
         texture = new Texture2D(1, 1, TextureFormat.ARGB32, false);             // dummy texture so we can load into it
         PhotoIO.LoadImage(ref texture, id);
     }
 }
コード例 #4
0
 public void SaveImage()
 {
     if (image1.Source != null)
     {
         PhotoIO pi = new PhotoIO();
         PhotoIO.WriteImageToFile(image1.Source as WriteableBitmap);
     }
 }
コード例 #5
0
ファイル: PhotoIO.cs プロジェクト: sevenli777/Sprayscape-VR
    public static int SaveToLocalStore(RenderTexture tex)
    {
        if (tex != null)
        {
            RenderTexture previous = RenderTexture.active;
            RenderTexture.active = tex;

            if (PhotoIO.saveBuffer == null)
            {
                PhotoIO.saveBuffer = new Texture2D(2048, 1024);
            }
            // Copy the current spray into the texture buffer and thumbnail.
            PhotoIO.saveBuffer.ReadPixels(new Rect(0, 0, 2048, 1024), 0, 0);

            RenderTexture.active = previous;

            byte[] bytes = PhotoIO.saveBuffer.EncodeToJPG(100);
            bytes = PhotoIO.Append360Exif(bytes);

            if (bytes != null)
            {
                Debug.Log(Application.persistentDataPath);
                //------------------------------------------------
                int    nextID   = GetNextID();
                string filePath = Path(nextID);
                //------------------------------------------------
                InsertThumbnail(tex, nextID);
                SaveThumbnailImage();
                //------------------------------------------------

                //SaveFilePaths();

                try{
                    File.WriteAllBytes(filePath, bytes);
                }
                catch (System.ArgumentException) {
                    return(-1);
                }
                catch (System.IO.IOException) {
                    return(-1);
                }
                catch (System.UnauthorizedAccessException) {
                    return(-1);
                }
                catch (System.NotSupportedException) {
                    return(-1);
                }
                catch (System.Security.SecurityException) {
                    return(-1);
                }

                return(nextID);
            }
        }

        return(-1);
    }
コード例 #6
0
    void LoadSprays()
    {
        PhotoIO.LoadFilePaths();

        for (int i = 0; i < PhotoIO.saveMap.Count; i++)
        {
            var s = new SavedSpray(PhotoIO.saveMap[i], i);
            sprays.Add(s);
        }

        PhotoIO.LoadThumbnailImage();
    }
コード例 #7
0
 public void SaveImage()
 {
     if (ProcessImageCanvas.getPhoto() != null)
     {
         PhotoIO pi = new PhotoIO();
         PhotoIO.WriteImageToFile(ProcessImageCanvas.getPhoto());
     }
     if (PhotoOperate != null)
     {
         PhotoOperate("Save", ProcessImageCanvas.getPhoto());
     }
 }
コード例 #8
0
        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            if (lcp == null)
            {
                SilverlightLFC.common.Environment.ShowMessage("未将按钮和测试对象关联!"); return;
            }
            WriteableBitmap b = lcp.getPhoto();

            if (b != null)
            {
                PhotoIO pi = new PhotoIO();
                PhotoIO.WriteImageToFile(b);
            }
        }
コード例 #9
0
        private void buttonImport_Click(object sender, RoutedEventArgs e)
        {
            if (lcp == null)
            {
                SilverlightLFC.common.Environment.ShowMessage("未将按钮和测试对象关联!"); return;
            }
            var b = PhotoIO.ReadImageFromFile();

            if (b == null)
            {
                return;
            }

            lcp.setPhoto(b.Result);
        }
コード例 #10
0
    private void CreateListElement(ISpray spray)
    {
        spray.OrderChanged += Spray_OrderChanged;

        GameObject go = Instantiate(listElementPrefab);

        go.name = "Photo Id " + spray.Id;
        go.SetActive(false);

        LibraryListElement elem = go.GetComponent <LibraryListElement>();

        elem.spray             = spray;
        elem.libraryController = this;

        // use the ScrollRect as the vertical drag handler
        LockedDragHandler lockedDragHandler = elem.GetComponent <LockedDragHandler>();

        lockedDragHandler.verticalEventReceiver = scrollRect.GetComponent <LockedDragForwarder>();

        int x = PhotoIO.GetThumbnailX(spray.Id);
        int y = PhotoIO.GetThumbnailY(spray.Id);

        // we need to deal with the half texel offset, but this creates a 1 pixel discontinuity, since the atan2 edge should overlap
        Vector4 texParams = new Vector4(x * PhotoIO.ThumbnailSizeX + PhotoIO.HalfPixel,
                                        y * PhotoIO.ThumbnailSizeY + PhotoIO.HalfPixel,
                                        PhotoIO.PanoScalingX * PhotoIO.ThumbnailSizeX,
                                        PhotoIO.PanoScalingY * PhotoIO.ThumbnailSizeY);

        // set the spray texture
        elem.sprayCanvas.material = Instantiate(elem.sprayCanvas.material);         // clone material for unique _TexParams
        elem.sprayCanvas.material.SetVector("_TexParams", texParams);
        elem.sprayCanvas.texture = PhotoIO.thumbnails;

        // set the label text
        elem.labelText.text = spray.Label;

        // anchor the list element to the content rect
        elem.scrollTransform.SetParent(contentRoot);
        elem.scrollTransform.offsetMin        = new Vector2(0, elem.scrollTransform.offsetMin.y);
        elem.scrollTransform.offsetMax        = new Vector2(0, elem.scrollTransform.offsetMax.y);
        elem.scrollTransform.anchoredPosition = new Vector2(0, 0);
        elem.scrollTransform.localScale       = Vector3.one;

        elem.DrawerPeeked += LibraryListElement_DrawerPeeked;
        elem.DrawerOpened += LibraryListElement_DrawerOpened;

        elementLookup[spray.Id] = elem;
    }
コード例 #11
0
    public void DeleteSpray(ISpray spray)
    {
        Debug.Log("Deleting spray");
        spray.UnloadTexture();
        sprays.Remove(spray);

        PhotoIO.DeleteImage(spray.Id);

        googleAnalytics.LogEvent("Spray", "Delete", spray.Id.ToString(), 1);
        // we need to update the spray ordering so the list view can update
        // for now just update them all, only ones that change will fire a change event
        for (int i = 0; i < sprays.Count; i++)
        {
            sprays[i].Order = i;
        }

        Blank = true;

        if (SprayDeleted != null)
        {
            SprayDeleted(spray);
        }
    }
コード例 #12
0
        public void OpenImage()
        {
            var tb = PhotoIO.ReadMultiImageFromFile();

            if (tb == null)
            {
                return;
            }

            List <WriteableBitmap> bl = tb.Result;

            if (bl == null)
            {
                return;
            }
            foreach (WriteableBitmap b in bl)
            {
                TargetControl.AddPhoto(b);
                if (PhotoOperate != null)
                {
                    PhotoOperate("Open", ProcessImageCanvas.getPhoto());
                }
            }
        }
コード例 #13
0
        private void buttonImport_Click(object sender, RoutedEventArgs e)
        {
            if (lcp == null)
            {
                SilverlightLFC.common.Environment.ShowMessage("未将按钮和测试对象关联!"); return;
            }
            ClearActiveAll();
            var b = PhotoIO.ReadImageFromFile();

            if (b == null)
            {
                return;
            }

            lcp.setPhoto(b.Result);
            if (addPhoto != null)
            {
                addPhoto(b.Result);
            }
            if (PhotoOperate != null)
            {
                PhotoOperate("Import", b.Result);
            }
        }
コード例 #14
0
 public int Save()
 {
     return(PhotoIO.SaveToLocalStore(sprayComposite));
 }
コード例 #15
0
 public WriteableBitmap OpenImage()
 {
     return(PhotoIO.ReadImageFromFile().Result);
 }