using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Swash.Objects;
using Swash.BusinessLayer;
using System.Data.SqlClient;
namespace POS
{
public partial class frmCropImage : Form
{
frmCustomer cust;
public byte[] CropImag;
int cropX;
int cropY;
int cropWidth;
int cropHeight;
int oCropX;
int oCropY;
public Pen cropPen;
public Bitmap _img;
public DashStyle cropDashStyle = DashStyle.DashDot;
public frmCropImage( )
{
InitializeComponent();
}
private void frmCropImage_Load(object sender, EventArgs e)
{
//frmCustomer obj=new frmCustomer();
string Path = frmCustomer.ImagPath;
pbimage.Image = new Bitmap(Path);
}
private void btnCrop_Click(object sender, EventArgs e)
{
Cursor = Cursors.Default;
try
{
if (cropWidth < 1)
{
return;
}
Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
//First we define a rectangle with the help of already calculated points
Bitmap OriginalImage = new Bitmap(pbimage.Image, pbimage.Width, pbimage.Height);
//Original image
_img = new Bitmap(cropWidth, cropHeight);
// for cropinf image
Graphics g = Graphics.FromImage(_img);
// create graphics
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
//set image attributes
g.DrawImage(OriginalImage, 0, 0, rect, GraphicsUnit.Pixel);
pbimage.Image = _img;
pbimage.Width = _img.Width;
pbimage.Height = _img.Height;
// PictureBoxLocation();
btnCrop.Enabled = false;
//obj.PictureBoxCustomer.Image = null;
//obj.PictureBoxCustomer.Image = _img;
//Image img = _img;
//using (MemoryStream ms = new MemoryStream())
//{
// img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
// CropImag = ms.ToArray();
//}
}
catch (Exception ex)
{
}
}
//private void PictureBoxLocation()
//{
// int _x = 0;
// int _y = 0;
// if (SplitContainer1.Panel1.Width > PictureBox1.Width)
// {
// _x = (SplitContainer1.Panel1.Width - PictureBox1.Width) / 2;
// }
// if (SplitContainer1.Panel1.Height > PictureBox1.Height)
// {
// _y = (SplitContainer1.Panel1.Height - PictureBox1.Height) / 2;
// }
// PictureBox1.Location = new Point(_x, _y);
//}
private void frmCropImage_MouseDown(object sender, MouseEventArgs e)
{
//if (e.Button == System.Windows.Forms.MouseButtons.Left)
//{
// Cursor = Cursors.Cross;
// cropX = e.X;
// cropY = e.Y;
// cropPen = new Pen(Color.Black, 1);
// cropPen.DashStyle = DashStyle.DashDotDot;
//}
//pbimage.Refresh();
}
private void frmCropImage_MouseMove(object sender, MouseEventArgs e)
{
//if (pbimage.Image == null)
// return;
//if (e.Button == System.Windows.Forms.MouseButtons.Left)
//{
// pbimage.Refresh();
// cropWidth = e.X - cropX;
// cropHeight = e.Y - cropY;
// pbimage.CreateGraphics().DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight);
//}
}
private void pbimage_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
Cursor = Cursors.Cross;
cropX = e.X;
cropY = e.Y;
cropPen = new Pen(Color.Black, 1);
cropPen.DashStyle = DashStyle.DashDotDot;
}
pbimage.Refresh();
}
private void pbimage_MouseMove(object sender, MouseEventArgs e)
{
if (pbimage.Image == null)
return;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
pbimage.Refresh();
cropWidth = e.X - cropX;
cropHeight = e.Y - cropY;
pbimage.CreateGraphics().DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight);
}
}
private void pbimage_MouseUp(object sender, MouseEventArgs e)
{
Cursor = Cursors.Default;
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Swash.Objects;
using Swash.BusinessLayer;
using System.Data.SqlClient;
namespace POS
{
public partial class frmCropImage : Form
{
frmCustomer cust;
public byte[] CropImag;
int cropX;
int cropY;
int cropWidth;
int cropHeight;
int oCropX;
int oCropY;
public Pen cropPen;
public Bitmap _img;
public DashStyle cropDashStyle = DashStyle.DashDot;
public frmCropImage( )
{
InitializeComponent();
}
private void frmCropImage_Load(object sender, EventArgs e)
{
//frmCustomer obj=new frmCustomer();
string Path = frmCustomer.ImagPath;
pbimage.Image = new Bitmap(Path);
}
private void btnCrop_Click(object sender, EventArgs e)
{
Cursor = Cursors.Default;
try
{
if (cropWidth < 1)
{
return;
}
Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
//First we define a rectangle with the help of already calculated points
Bitmap OriginalImage = new Bitmap(pbimage.Image, pbimage.Width, pbimage.Height);
//Original image
_img = new Bitmap(cropWidth, cropHeight);
// for cropinf image
Graphics g = Graphics.FromImage(_img);
// create graphics
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
//set image attributes
g.DrawImage(OriginalImage, 0, 0, rect, GraphicsUnit.Pixel);
pbimage.Image = _img;
pbimage.Width = _img.Width;
pbimage.Height = _img.Height;
// PictureBoxLocation();
btnCrop.Enabled = false;
//obj.PictureBoxCustomer.Image = null;
//obj.PictureBoxCustomer.Image = _img;
//Image img = _img;
//using (MemoryStream ms = new MemoryStream())
//{
// img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
// CropImag = ms.ToArray();
//}
}
catch (Exception ex)
{
}
}
//private void PictureBoxLocation()
//{
// int _x = 0;
// int _y = 0;
// if (SplitContainer1.Panel1.Width > PictureBox1.Width)
// {
// _x = (SplitContainer1.Panel1.Width - PictureBox1.Width) / 2;
// }
// if (SplitContainer1.Panel1.Height > PictureBox1.Height)
// {
// _y = (SplitContainer1.Panel1.Height - PictureBox1.Height) / 2;
// }
// PictureBox1.Location = new Point(_x, _y);
//}
private void frmCropImage_MouseDown(object sender, MouseEventArgs e)
{
//if (e.Button == System.Windows.Forms.MouseButtons.Left)
//{
// Cursor = Cursors.Cross;
// cropX = e.X;
// cropY = e.Y;
// cropPen = new Pen(Color.Black, 1);
// cropPen.DashStyle = DashStyle.DashDotDot;
//}
//pbimage.Refresh();
}
private void frmCropImage_MouseMove(object sender, MouseEventArgs e)
{
//if (pbimage.Image == null)
// return;
//if (e.Button == System.Windows.Forms.MouseButtons.Left)
//{
// pbimage.Refresh();
// cropWidth = e.X - cropX;
// cropHeight = e.Y - cropY;
// pbimage.CreateGraphics().DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight);
//}
}
private void pbimage_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
Cursor = Cursors.Cross;
cropX = e.X;
cropY = e.Y;
cropPen = new Pen(Color.Black, 1);
cropPen.DashStyle = DashStyle.DashDotDot;
}
pbimage.Refresh();
}
private void pbimage_MouseMove(object sender, MouseEventArgs e)
{
if (pbimage.Image == null)
return;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
pbimage.Refresh();
cropWidth = e.X - cropX;
cropHeight = e.Y - cropY;
pbimage.CreateGraphics().DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight);
}
}
private void pbimage_MouseUp(object sender, MouseEventArgs e)
{
Cursor = Cursors.Default;
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
I'm on the fence about this, while more customization is good, I have a feeling this is a "in-progress" update, it just feels incomplete and half-way there.
ReplyDeleteWe use badge layout for apps on design approvals (visual projects), so the image being displayed is important. Old layout "feels like" it had larger images,
maybe because the images were cropped more loosely so it's easier to tell which project it was at quick glance. Now the image is cropped closer, making it
harder to scan thru at quick glance. I find myself needing to click into the project more often than usual. Which makes the whole user experience less
efficient.
I have a couple suggestions that might make it work better:
1. Increase the height of the window the cover image is being displayed.
2. Let us to choose which image to be displayed as "cover" (like how Pinterest handles cover images of each board, was hoping for this for a long time)
3. Let us adjust which part of the image to show and how tight or loose the crop is (with a fixed window, let us move the image around and maybe enlarge or
shrink it to control what shows thru the window. Pinterest does a limited form of this, which is very useful in making the cover image relevant)
4. Allow Cover Image to be ordered in different hierarchy (currently every element can be ordered differently except the Cover Image, it seems to be stuck
in the 2nd spot, would like the option to set it on another spot in the layout. This one seems like an easy fix, since you guys allow that for every other
element already)
I'm on the fence about this, while more customization is good, I have a feeling this is a "in-progress" update, it just feels incomplete and half-way there.
ReplyDeleteWe use badge layout for apps on design approvals (visual projects), so the image being displayed is important. Old layout "feels like" it had larger images,
maybe because the images were cropped more loosely so it's easier to tell which project it was at quick glance. Now the image is cropped closer, making it
harder to scan thru at quick glance. I find myself needing to click into the project more often than usual. Which makes the whole user experience less
efficient.
I have a couple suggestions that might make it work better:
1. Increase the height of the window the cover image is being displayed.
2. Let us to choose which image to be displayed as "cover" (like how Pinterest handles cover images of each board, was hoping for this for a long time)
3. Let us adjust which part of the image to show and how tight or loose the crop is (with a fixed window, let us move the image around and maybe enlarge or
shrink it to control what shows thru the window. Pinterest does a limited form of this, which is very useful in making the cover image relevant)
4. Allow Cover Image to be ordered in different hierarchy (currently every element can be ordered differently except the Cover Image, it seems to be stuck
in the 2nd spot, would like the option to set it on another spot in the layout. This one seems like an easy fix, since you guys allow that for every other
element already)