Adjusts the current format to the cropping parameter.<p>
428385
private void adjustToCurrentFormat() {

        // in case of a locked or fixed image ratio height and width need to be reset
        int height = m_croppingParam.getOrgHeight();
        int width = m_croppingParam.getOrgWidth();
        if (m_croppingParam.isScaled()) {
            if (m_croppingParam.getTargetHeight() == -1) {
                height = (int)Math.floor(
                    ((1.00 * m_croppingParam.getOrgHeight()) / m_croppingParam.getOrgWidth())
                        * m_croppingParam.getTargetWidth());
            } else {
                height = m_croppingParam.getTargetHeight();
            }
            if (m_croppingParam.getTargetWidth() == -1) {
                width = (int)Math.floor(
                    ((1.00 * m_croppingParam.getOrgWidth()) / m_croppingParam.getOrgHeight())
                        * m_croppingParam.getTargetHeight());
            } else {
                width = m_croppingParam.getTargetWidth();
            }

        } else {
            m_croppingParam.setTargetHeight(height);
            m_croppingParam.setTargetWidth(width);
        }
        m_formatForm.setHeightInput(height);
        m_formatForm.setWidthInput(width);
        // enabling/disabling ratio lock button
        if (m_currentFormat.isFixedRatio()) {
            m_formatForm.setRatioButton(false, false, Messages.get().key(Messages.GUI_PRIVIEW_BUTTON_RATIO_FIXED_0));
            m_ratioLocked = true;
        } else {
            if (!m_currentFormat.isHeightEditable() && !m_currentFormat.isWidthEditable()) {
                // neither height nor width are editable, disable ratio lock button
                m_formatForm.setRatioButton(
                    false,
                    false,
                    Messages.get().key(Messages.GUI_PRIVIEW_BUTTON_NOT_EDITABLE_0));
            } else {
                m_formatForm.setRatioButton(false, true, null);
            }
            m_ratioLocked = true;
        }
        // enabling/disabling height and width input
        m_formatForm.setHeightInputEnabled(m_currentFormat.isHeightEditable() || hasUserFormatRestriction());
        m_formatForm.setWidthInputEnabled(m_currentFormat.isWidthEditable() || hasUserFormatRestriction());
    }
920761
public void cropTo(int fromItem, int toItem) {
        fromItem = Math.max(fromItem, 0);
        toItem = Math.min(toItem, cells.size());
        cells.forget(0, fromItem);
        cells.forget(toItem, cells.size());
    }
465319
@SuppressWarnings("DeprecatedIsStillUsed")
    @Deprecated
    public static Bitmap crop(Drawable drawable, State state, Settings settings) {
        if (drawable == null) {
            return null;
        }

        float zoom = state.getZoom();

        // Computing crop size for base zoom level (zoom == 1)
        int width = Math.round(settings.getMovementAreaW() / zoom);
        int height = Math.round(settings.getMovementAreaH() / zoom);

        // Crop area coordinates within viewport
        Rect pos = new Rect();
        GravityUtils.getMovementAreaPosition(settings, pos);

        Matrix matrix = new Matrix();
        state.get(matrix);
        // Scaling to base zoom level (zoom == 1)
        matrix.postScale(1f / zoom, 1f / zoom, pos.left, pos.top);
        // Positioning crop area
        matrix.postTranslate(-pos.left, -pos.top);

        try {
            // Draw drawable into bitmap
            Bitmap dst = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

            Canvas canvas = new Canvas(dst);
            canvas.concat(matrix);
            drawable.draw(canvas);

            return dst;
        } catch (OutOfMemoryError e) {
            return null; // Not enough memory for cropped bitmap
        }
    }
122464
public void onHeightChange(String height) {

        int value = CmsClientStringUtil.parseInt(height);
        if ((m_croppingParam.getTargetHeight() == value) || (value == 0)) {
            // the value has not changed, ignore'0'
            return;
        }
        m_croppingParam.setTargetHeight(value);
        if (m_ratioLocked) {
            m_croppingParam.setTargetWidth((value * m_originalWidth) / m_originalHeight);
            m_formatForm.setWidthInput(m_croppingParam.getTargetWidth());
        }
        // in case the width and height parameter don't match the current format any longer, switch to user defined format
        if ((!m_currentFormat.isHeightEditable() || (m_ratioLocked && !m_currentFormat.isWidthEditable()))
            && hasUserFormatRestriction()) {
            m_formatForm.setFormatSelectValue(m_userFormatKey);
        } else {
            fireValueChangedEvent();
        }
    }
619636
private static Bitmap crop(Bitmap srcBmp, View canvasView, int downsampling) {
        float scale = 1f / downsampling;
        return Bitmap.createBitmap(
                srcBmp,
                (int) Math.floor((ViewCompat.getX(canvasView)) * scale),
                (int) Math.floor((ViewCompat.getY(canvasView)) * scale),
                (int) Math.floor((canvasView.getWidth()) * scale),
                (int) Math.floor((canvasView.getHeight()) * scale)
        );
    }
938611
public void setFormEnabled(boolean enabled) {

        m_formEnabled = enabled;
        m_selectBox.setEnabled(enabled);
        m_heightBox.setEnabled(enabled);
        m_widthBox.setEnabled(enabled);
        if (enabled) {
            m_cropButton.enable();
            m_removeCropButton.enable();
        } else {
            m_cropButton.disable(Messages.get().key(Messages.GUI_IMAGE_NO_FORMATS_AVAILABLE_0));
            m_removeCropButton.disable(Messages.get().key(Messages.GUI_IMAGE_NO_FORMATS_AVAILABLE_0));
        }
    }
732345
private StreamConfiguration adjustConfigurations(AudioFormat format) {
    int sampleRate = (int) format.getSampleRate();
    int sampleSize = format.getSampleSizeInBits();
    int channels = format.getChannels();

    StreamConfiguration streamConfiguration = new StreamConfiguration();
    streamConfiguration.setSampleRate(sampleRate);
    streamConfiguration.setBitsPerSample(sampleSize);
    streamConfiguration.setChannelCount(channels);

    return streamConfiguration;
  }
510919
def fixed_crop(src, x0, y0, w, h, size=None, interpolation=cv2.INTER_CUBIC):
    """"""
    out = mx.nd.crop(src, begin=(y0, x0, 0), end=(y0+h, x0+w, int(src.shape[2])))
    if size is not None and (w, h) != size:
        out = resize(out, size, interpolation=interpolation)
    return out
983513
public void onResetSize() {

        String restrictionKey;
        if (m_formats.containsKey(DefaultRestriction.original.name())) {
            restrictionKey = DefaultRestriction.original.name();
        } else {
            restrictionKey = m_formats.keySet().iterator().next();
        }
        m_formatForm.setFormatSelectValue(restrictionKey);
        m_croppingParam.reset();
        onFormatChange(restrictionKey);
    }
447514
private void resizeValueText() {
        double maxWidth = size * 0.86466165;
        double fontSize = size * 0.2556391;
        valueText.setFont(Fonts.latoLight(fontSize));
        if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); }
        valueText.relocate((size - valueText.getLayoutBounds().getWidth()) * 0.5, (size - valueText.getLayoutBounds().getHeight()) * 0.5);
    }
551990
protected FormMappingOption adjustFormMapping() {
        final FormMappingOption option = getAdjustmentProvider().adjustFormMapping();
        return option != null ? option : NULLOBJ_FORM_MAPPING_OPTION;
    }
82775
function crop(stream, config, cb) {
  PNGCrop.cropToStream(stream, config, function(err, outputStream) {
    var buf = concat(function(data) {
      cb(err, data);
    });
    outputStream.pipe(buf);
  });
}
1015952
private void adjustSchema(String schemaPath, String newElementString) {

        newElementString = newElementString.substring(0, 1).toUpperCase() + newElementString.substring(1);
        try {
            CmsFile file = m_cms.readFile(schemaPath);

            CmsMacroResolver macroResolver = new CmsMacroResolver();
            macroResolver.setKeepEmptyMacros(true);

            macroResolver.addMacro(SAMPLE_TYPE_SCHEMA_ELEMENT, newElementString);
            String bundleName = m_bundle.getValue();

            bundleName = bundleName.split("/")[bundleName.split("/").length - 1];
            if (bundleName.contains("_")) {
                bundleName = bundleName.split("_")[0];
            }
            macroResolver.addMacro("ResourceBundle", bundleName);
            macroResolver.addMacro("typeName", m_typeShortName.getValue());
            String encoding = m_cms.readPropertyObject(
                file,
                CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING,
                true).getValue(OpenCms.getSystemInfo().getDefaultEncoding());
            String newContent = macroResolver.resolveMacros(new String(file.getContents(), encoding));
            // update the content
            try {
                file.setContents(newContent.getBytes(encoding));
            } catch (UnsupportedEncodingException e) {
                try {
                    file.setContents(newContent.getBytes(Charset.defaultCharset().toString()));
                } catch (UnsupportedEncodingException e1) {
                    file.setContents(newContent.getBytes());
                }
            }
            // write the target file
            CmsLockUtil.ensureLock(m_cms, file);
            m_cms.writeFile(file);
            CmsLockUtil.tryUnlock(m_cms, file);
        } catch (

        CmsException e) {
            LOG.error("Unable to read schema definition", e);
        } catch (UnsupportedEncodingException e) {
            LOG.error("Unable to fetch encoding", e);
        }
    }
288021
public void trimToSize() {
        modCount++;
        int oldCapacity = elementData.length;
        if (size < oldCapacity) {
            elementData = Arrays.copyOf(elementData, size);
        }
    }
1048394
function Cropper(element) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    classCallCheck(this, Cropper);

    if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
      throw new Error('The first argument is required and must be an <img> or <canvas> element.');
    }

    this.element = element;
    this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
    this.cropped = false;
    this.disabled = false;
    this.pointers = {};
    this.ready = false;
    this.reloading = false;
    this.replaced = false;
    this.sized = false;
    this.sizing = false;
    this.init();
  }
764874
private void adaptWidth() {
        adapter.setWidth(width);

        if (rootView != null) {
            rootView.setWidth(width);
            rootView.requestLayout();
        }
    }
443343
def crop_resized(image, size, gravity = "Center")
      size =~ /(\d+)x(\d+)/
      width = $1.to_i
      height = $2.to_i

      # Grab the width and height of the current image in one go.
      cols, rows = image[:dimensions]

      # Only do anything if needs be. Who knows, maybe it's already the exact
      # dimensions we're looking for.
      if(width != cols && height != rows)
        image.combine_options do |c|
          # Scale the image down to the widest dimension.
          if(width != cols || height != rows)
            scale = [width / cols.to_f, height / rows.to_f].max * 100
            c.resize("#{scale}%")
          end

          # Align how things will be cropped.
          c.gravity(gravity)

          # Crop the image to size.
          c.crop("#{width}x#{height}+0+0")
        end
      end
    end