asp .net හෝ C# දන්නා කෙනෙක්ගෙන් මට ලොකු උදව්වක් ඕනේ

baaron

Member
Jul 13, 2011
451
21
0
asp .net හෝ C# දන්නා කෙනෙක්ගෙන් මට ලොකු උදව්වක් ඕනේ

asp .net හෝ C# දන්නා කෙනෙක්ගෙන් මට ලොකු උදව්වක් ඕනේ.යාලුවනේ මන් අපේ ප්‍රොජෙක්ට් එකකට වෙබ් සයිට් එකක් හදනවා:yes:
මෙහෙමයි එකේ වැඩ වෙන්නේ
user කෙනෙක්ට log වෙලා image upload කරන්නයි upload කරපු images නැවතත් පොඩි වින්ඩොව් එකක view කරලා එක crop කරලා නැවතත් save කරන්නයි ඕනේ.
මට image එක server එකේ save කරන්න හදන ටික ශේප්
එත් ඒක Edit image වෙනම වින්ඩොව් එකක පෙන්නලා edit කරන්න කරන වැඩ ටික තමා තේරෙන්නේ නැත්තේ:no:
මන් upload වෙන images save කරන්නේ database එකේ නම් නෙමේ වෙනම folder එකකටයි.එතනින් එක වෙනම view කරලා edit කරන්න යනකන් දන්නා කෙනෙක් ඉන්නවා නම් මට කියල දෙන්න පුලුවන්ද
පුලුවන් නම් මේ උදව්ව කරලා දෙන්න ලොකු දෙයක් යාලුවනේ.මාව මේ පාර්ට් එකේ හිර වෙලා තියෙන්නේ එකයි :no:
 

baaron

Member
Jul 13, 2011
451
21
0
Crop karannath ona System akenmada? Man ahuwe Editor akakin da naththan code aken crop kalata kamak nadda?

code eken crop karata kamk na.e kiyanne apita one thanata move karala one size ekata crop kara gnnai mata one machn.
 

K_ZONE

Well-known member
  • May 28, 2009
    5,176
    4,088
    113
    invoke db "Injected Memory"
    fatta fata fata

    මමත් මෙ ඔතනමයි බන් දැන් එරිල ඉන්නෙ. ASP නම් නෙමෙයි Winforms
    මටත් ඕන Webcam image එකක් අරගෙන්, එක Resize කරල Database එකට යවන්න,Webcam capture , Resize, Crop ඔක්කොටම වෙන වෙනම Dll හඩ ගත්ත ඒටික සුපිරියට වැඩ, එත් Image එකක් උඩ Box එකක් ඇදලා Crop කරන්න බැ බං තාම, අට ඕන FaceBook එකේ වගේ එකක් හදන්න, පොඩි Idea එකක් තියෙන්වා, හරි ගියොත් කියන්නම්,

    මේ දැනට . . .


    27279468.png
     
    Last edited:

    baaron

    Member
    Jul 13, 2011
    451
    21
    0
    මමත් මෙ ඔතනමයි බන් දැන් එරිල ඉන්නෙ. ASP නම් නෙමෙයි Winforms
    මටත් ඕන Webcam image එකක් අරගෙන්, එක Resize කරල Database එකට යවන්න,Webcam capture , Resize, Crop ඔක්කොටම වෙන වෙනම Dll හඩ ගත්ත ඒටික සුපිරියට වැඩ, එත් Image එකක් උඩ Box එකක් ඇදලා Crop කරන්න බැ බං තාම, අට ඕන FaceBook එකේ වගේ එකක් හදන්න, පොඩි Idea එකක් තියෙන්වා, හරි ගියොත් කියන්නම්,

    මේ දැනට . . .


    27279468.png

    machn uba image eka dn thiyena system eke crop karanne mna widiyatada?
    thawa ekak machn uba web cam eken image ekak gattama eka save wnna damme kohetada? (mama nm foder ekakta save wnna damme)
    thawa ekak machn uba image eka edit karala save karama kln thibba image eka replace wnna neda haduwe?
     

    K_ZONE

    Well-known member
  • May 28, 2009
    5,176
    4,088
    113
    invoke db "Injected Memory"
    machn uba image eka dn thiyena system eke crop karanne mna widiyatada?
    thawa ekak machn uba web cam eken image ekak gattama eka save wnna damme kohetada? (mama nm foder ekakta save wnna damme)
    thawa ekak machn uba image eka edit karala save karama kln thibba image eka replace wnna neda haduwe?


    හ්ම්. . . මගෙ system එකේ කොහෙවත් Save වෙන්නෙ නැ බං, 3rd party Libraries use කරෙ නැති හින්දා මම කෙලින්ම Image එකම pass කරනවා,

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Drawing;
    using System.IO;
    using System.Drawing.Imaging;
    using System.Drawing.Drawing2D;
    
    namespace Skynet.ImageProsses
    {
        public class ImageProsses
        {
            //Overload for crop that default starts top left of the image.
            public static Image CropImage(System.Drawing.Image Image, int Height, int Width)
            {
                return CropImage(Image, Height, Width, 0, 0);
            }
    
            //The crop image sub
            public static System.Drawing.Image CropImage(System.Drawing.Image Image, int Height, int Width, int StartAtX, int StartAtY)
            {
                Image outimage;
                MemoryStream mm = null;
                try
                {
                    //check the image height against our desired image height
                    if (Image.Height < Height)
                    {
                        Height = Image.Height;
                    }
    
                    if (Image.Width < Width)
                    {
                        Width = Image.Width;
                    }
    
                    //create a bitmap window for cropping
                    Bitmap bmPhoto = new Bitmap(Width, Height, PixelFormat.Format24bppRgb);
                    bmPhoto.SetResolution(72, 72);
    
                    //create a new graphics object from our image and set properties
                    Graphics grPhoto = Graphics.FromImage(bmPhoto);
                    grPhoto.SmoothingMode = SmoothingMode.AntiAlias;
                    grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    grPhoto.PixelOffsetMode = PixelOffsetMode.HighQuality;
    
                    //now do the crop
                    grPhoto.DrawImage(Image, new Rectangle(0, 0, Width, Height), StartAtX, StartAtY, Width, Height, GraphicsUnit.Pixel);
    
                    // Save out to memory and get an image from it to send back out the method.
                    mm = new MemoryStream();
                    bmPhoto.Save(mm, System.Drawing.Imaging.ImageFormat.Jpeg);
                    Image.Dispose();
                    bmPhoto.Dispose();
                    grPhoto.Dispose();
                    outimage = Image.FromStream(mm);
    
                    return outimage;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error cropping image, the error was: " + ex.Message);
                }
            }
    
            //Hard resize attempts to resize as close as it can to the desired size and then crops the excess
            public static System.Drawing.Image HardResizeImage(int Width, int Height, System.Drawing.Image Image)
            {
                int width = Image.Width;
                int height = Image.Height;
                Image resized = null;
                if (Width > Height)
                {
                    resized = ResizeImage(Width, Width, Image);
                }
                else
                {
                    resized = ResizeImage(Height, Height, Image);
                }
                Image output = CropImage(resized, Height, Width);
                //return the original resized image
                return output;
            }
    
            //Image resizing
            public static System.Drawing.Image ResizeImage(int maxWidth, int maxHeight, System.Drawing.Image Image)
            {
                int width = Image.Width;
                int height = Image.Height;
                if (width > maxWidth || height > maxHeight)
                {
                    //The flips are in here to prevent any embedded image thumbnails -- usually from cameras
                    //from displaying as the thumbnail image later, in other words, we want a clean
                    //resize, not a grainy one.
                    Image.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
                    Image.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
    
                    float ratio = 0;
                    if (width > height)
                    {
                        ratio = (float)width / (float)height;
                        width = maxWidth;
                        height = Convert.ToInt32(Math.Round((float)width / ratio));
                    }
                    else
                    {
                        ratio = (float)height / (float)width;
                        height = maxHeight;
                        width = Convert.ToInt32(Math.Round((float)height / ratio));
                    }
    
                    //return the resized image
                    return Image.GetThumbnailImage(width, height, null, IntPtr.Zero);
                }
                //return the original resized image
                return Image;
            }
            public Image ResizeImage(Image FullsizeImage, int NewWidth, int MaxHeight, bool OnlyResizeIfWider = true)
            {
                // Prevent using images internal thumbnail
                FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
                FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
    
                if (OnlyResizeIfWider)
                {
                    if (FullsizeImage.Width <= NewWidth)
                    {
                        NewWidth = FullsizeImage.Width;
                    }
                }
    
                int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;
                if (NewHeight > MaxHeight)
                {
                    // Resize with height instead
                    NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;
                    NewHeight = MaxHeight;
                }
    
                Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);
    
                // Clear handle to original file so that we can overwrite it if necessary
                FullsizeImage.Dispose();
    
                // Save resized picture
                return NewImage;
            }
    
        }
    }

    System.Drawing.Imaging.image Type එකේ තමයි image එක Save වෙන කල්ම තියෙන්නෙ,. අන්තිමට කපලා කොටලා ඉවර උන Image එක Base64 encode කරලා, Bitstream එකක් විදියට SQL server එකෙ තමයි තියන්නෙ. . Image එක Image එකක් විදියට ගන්නෙ නැ කොහෙවත් ..
     

    baaron

    Member
    Jul 13, 2011
    451
    21
    0

    හ්ම්. . . මගෙ system එකේ කොහෙවත් Save වෙන්නෙ නැ බං, 3rd party Libraries use කරෙ නැති හින්දා මම කෙලින්ම Image එකම pass කරනවා,

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Drawing;
    using System.IO;
    using System.Drawing.Imaging;
    using System.Drawing.Drawing2D;
    
    namespace Skynet.ImageProsses
    {
        public class ImageProsses
        {
            //Overload for crop that default starts top left of the image.
            public static Image CropImage(System.Drawing.Image Image, int Height, int Width)
            {
                return CropImage(Image, Height, Width, 0, 0);
            }
    
            //The crop image sub
            public static System.Drawing.Image CropImage(System.Drawing.Image Image, int Height, int Width, int StartAtX, int StartAtY)
            {
                Image outimage;
                MemoryStream mm = null;
                try
                {
                    //check the image height against our desired image height
                    if (Image.Height < Height)
                    {
                        Height = Image.Height;
                    }
    
                    if (Image.Width < Width)
                    {
                        Width = Image.Width;
                    }
    
                    //create a bitmap window for cropping
                    Bitmap bmPhoto = new Bitmap(Width, Height, PixelFormat.Format24bppRgb);
                    bmPhoto.SetResolution(72, 72);
    
                    //create a new graphics object from our image and set properties
                    Graphics grPhoto = Graphics.FromImage(bmPhoto);
                    grPhoto.SmoothingMode = SmoothingMode.AntiAlias;
                    grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    grPhoto.PixelOffsetMode = PixelOffsetMode.HighQuality;
    
                    //now do the crop
                    grPhoto.DrawImage(Image, new Rectangle(0, 0, Width, Height), StartAtX, StartAtY, Width, Height, GraphicsUnit.Pixel);
    
                    // Save out to memory and get an image from it to send back out the method.
                    mm = new MemoryStream();
                    bmPhoto.Save(mm, System.Drawing.Imaging.ImageFormat.Jpeg);
                    Image.Dispose();
                    bmPhoto.Dispose();
                    grPhoto.Dispose();
                    outimage = Image.FromStream(mm);
    
                    return outimage;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error cropping image, the error was: " + ex.Message);
                }
            }
    
            //Hard resize attempts to resize as close as it can to the desired size and then crops the excess
            public static System.Drawing.Image HardResizeImage(int Width, int Height, System.Drawing.Image Image)
            {
                int width = Image.Width;
                int height = Image.Height;
                Image resized = null;
                if (Width > Height)
                {
                    resized = ResizeImage(Width, Width, Image);
                }
                else
                {
                    resized = ResizeImage(Height, Height, Image);
                }
                Image output = CropImage(resized, Height, Width);
                //return the original resized image
                return output;
            }
    
            //Image resizing
            public static System.Drawing.Image ResizeImage(int maxWidth, int maxHeight, System.Drawing.Image Image)
            {
                int width = Image.Width;
                int height = Image.Height;
                if (width > maxWidth || height > maxHeight)
                {
                    //The flips are in here to prevent any embedded image thumbnails -- usually from cameras
                    //from displaying as the thumbnail image later, in other words, we want a clean
                    //resize, not a grainy one.
                    Image.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
                    Image.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
    
                    float ratio = 0;
                    if (width > height)
                    {
                        ratio = (float)width / (float)height;
                        width = maxWidth;
                        height = Convert.ToInt32(Math.Round((float)width / ratio));
                    }
                    else
                    {
                        ratio = (float)height / (float)width;
                        height = maxHeight;
                        width = Convert.ToInt32(Math.Round((float)height / ratio));
                    }
    
                    //return the resized image
                    return Image.GetThumbnailImage(width, height, null, IntPtr.Zero);
                }
                //return the original resized image
                return Image;
            }
            public Image ResizeImage(Image FullsizeImage, int NewWidth, int MaxHeight, bool OnlyResizeIfWider = true)
            {
                // Prevent using images internal thumbnail
                FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
                FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
    
                if (OnlyResizeIfWider)
                {
                    if (FullsizeImage.Width <= NewWidth)
                    {
                        NewWidth = FullsizeImage.Width;
                    }
                }
    
                int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;
                if (NewHeight > MaxHeight)
                {
                    // Resize with height instead
                    NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;
                    NewHeight = MaxHeight;
                }
    
                Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);
    
                // Clear handle to original file so that we can overwrite it if necessary
                FullsizeImage.Dispose();
    
                // Save resized picture
                return NewImage;
            }
    
        }
    }

    System.Drawing.Imaging.image Type එකේ තමයි image එක Save වෙන කල්ම තියෙන්නෙ,. අන්තිමට කපලා කොටලා ඉවර උන Image එක Base64 encode කරලා, Bitstream එකක් විදියට SQL server එකෙ තමයි තියන්නෙ. . Image එක Image එකක් විදියට ගන්නෙ නැ කොහෙවත් ..
    :baffled: meka dakkama chain paninwa.thnkz macho.but mage eke me widiyata neme system eka yanne.eke aniwa image eka save karalai wada karanna ganne.bt samahara than nm similar ynwa