|
Revision 12256, 1.5 KB
(checked in by bayral, 21 months ago)
|
|
adding PiwigoUpload project for a simple tools for upload your photo recursively
|
| Line | |
|---|
| 1 | using System; |
|---|
| 2 | using System.Collections.Generic; |
|---|
| 3 | using System.Linq; |
|---|
| 4 | using System.Text; |
|---|
| 5 | |
|---|
| 6 | using System.IO; |
|---|
| 7 | |
|---|
| 8 | namespace Com.Piwigo.Uploader.Helper |
|---|
| 9 | { |
|---|
| 10 | internal static class MainAppHelper |
|---|
| 11 | { |
|---|
| 12 | internal static void showdErrorMessageBox(ApplicationException aEx) |
|---|
| 13 | { |
|---|
| 14 | System.Windows.Forms.MessageBox.Show(aEx.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | #region thumb |
|---|
| 19 | internal static string MakeThumb(FileInfo fi, String ext, int size) |
|---|
| 20 | { |
|---|
| 21 | // create an image object, using the filename we just retrieved |
|---|
| 22 | System.Drawing.Image image = System.Drawing.Image.FromFile(fi.FullName); |
|---|
| 23 | |
|---|
| 24 | // create the actual thumbnail image |
|---|
| 25 | System.Drawing.Image thumbnailImage = image.GetThumbnailImage(size, size, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); |
|---|
| 26 | |
|---|
| 27 | // make a memory stream to work with the image bytes |
|---|
| 28 | FileStream imageStream = new FileStream(ext, FileMode.OpenOrCreate); |
|---|
| 29 | |
|---|
| 30 | // put the image into the memory stream |
|---|
| 31 | thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg); |
|---|
| 32 | |
|---|
| 33 | imageStream.Close(); |
|---|
| 34 | return ext; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | /// <summary> |
|---|
| 38 | /// Required, but not used |
|---|
| 39 | /// </summary> |
|---|
| 40 | /// <returns>true</returns> |
|---|
| 41 | internal static bool ThumbnailCallback() |
|---|
| 42 | { |
|---|
| 43 | return true; |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | #endregion thumb |
|---|
| 47 | } |
|---|
| 48 | } |
|---|