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(); }
public SavedSpray(int id, int order) { this.id = id; this.order = order; this.label = PhotoIO.PhotoLabel(id); this.thumbnail = PhotoIO.thumbnails; }
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); } }
public void SaveImage() { if (image1.Source != null) { PhotoIO pi = new PhotoIO(); PhotoIO.WriteImageToFile(image1.Source as WriteableBitmap); } }
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); }
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(); }
public void SaveImage() { if (ProcessImageCanvas.getPhoto() != null) { PhotoIO pi = new PhotoIO(); PhotoIO.WriteImageToFile(ProcessImageCanvas.getPhoto()); } if (PhotoOperate != null) { PhotoOperate("Save", ProcessImageCanvas.getPhoto()); } }
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); } }
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); }
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; }
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); } }
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()); } } }
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); } }
public int Save() { return(PhotoIO.SaveToLocalStore(sprayComposite)); }
public WriteableBitmap OpenImage() { return(PhotoIO.ReadImageFromFile().Result); }