ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Member Functions | Properties | List of all members
ImageResizer.Plugins.SeamCarving.CarveDataPlotter Class Reference

Public Member Functions

void Init (string data)
 
void SaveBitmapAs (string path, int width, int height)
 
Size GetRemovalSpace (int w, int h, int blockSize)
 Returns the minimum width (if vertical seams are used) and minimum height (if horizontal seams are used) shrinkage needed to eliminate the marked removal areas. More...
 

Properties

int BlockCount [get, set]
 
int Stride [get, set]
 
int Rows [get, set]
 
byte[][] Grid [get, set]
 

Detailed Description

Definition at line 8 of file CarveDataPlotter.cs.

Member Function Documentation

Size ImageResizer.Plugins.SeamCarving.CarveDataPlotter.GetRemovalSpace ( int  w,
int  h,
int  blockSize 
)
inline

Returns the minimum width (if vertical seams are used) and minimum height (if horizontal seams are used) shrinkage needed to eliminate the marked removal areas.

Parameters
w
h
blockSize
Returns

Definition at line 66 of file CarveDataPlotter.cs.

66  {
67  //In an ideal scenario, we just have to count how many remove blocks exist in a single vertical or horizontal line.
68  int[] rows = new int[Rows];
69  int[] cols = new int[Stride];
70 
71  byte[][] gr = Grid;
72 
73  for (int y = 0; y < Rows; y++) {
74  for (int x = 0; x < Stride; x++) {
75  if ((gr[y][x] == 2)) {
76  if (y < Rows - 1 && x < Stride - 1) {
77  rows[y] += blockSize;
78  cols[x] += blockSize;
79  } else {
80  rows[y] += blockSize + Math.Min(0, w - (x + 1) * blockSize);
81  cols[x] += blockSize + Math.Min(0, h - (y + 1) * blockSize);
82  }
83  }
84  }
85  }
86 
87  int maxWidth = 0;
88  int maxHeight = 0;
89 
90  foreach (int i in rows)
91  if (i > maxWidth) maxWidth = i;
92 
93  foreach (int i in cols)
94  if (i > maxHeight) maxHeight = i;
95 
96  return new Size(maxWidth, maxHeight);
97  }

The documentation for this class was generated from the following file: