最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - How to capture large images beyond 2k*2k pixels without cropping? - Stack Overflow

programmeradmin3浏览0评论

I am trying capture large image from gojs with angular 17 from below code. But it captures image upto 2000*2000 pixels which either cropping it off or making it blur. Is there any way we can capture large images in gojs with angular 17 with full clarity without cropping it off. I tried by changing scale but its cropping the image.

public createImage(diagram: go.Diagram) {
    const bounds = diagram.documentBounds.copy();
    const imageDataOptions: any = this.createImageOptions(bounds);
    return diagram.makeImageData(imageDataOptions);
  }



  createImageOptions(bounds: go.Rect): go.ImageRendererOptions {
    const imageDataOptions: go.ImageRendererOptions = {
      background: 'white'
    }
    if (!_.isNaN(bounds.width) && !_.isNaN(bounds.height)) {
      if (bounds.height > DiagramImageUpperBond && bounds.height > bounds.width) {
        const newHeight = DiagramImageUpperBond;
        const newWidth = bounds.width - ((bounds.height - DiagramImageUpperBond) * (bounds.width / bounds.height))
        imageDataOptions.size = new go.Size(newWidth, newHeight);
      }
      else if (bounds.width > DiagramImageUpperBond && bounds.width > bounds.height) {
        const newWidth = DiagramImageUpperBond;
        const newHeight = bounds.height - ((bounds.width - DiagramImageUpperBond) * (bounds.height / bounds.width))
        imageDataOptions.size = new go.Size(newWidth, newHeight);
      }
      else {
        imageDataOptions.scale = 1
      }
    }
    return imageDataOptions;
  }
发布评论

评论列表(0)

  1. 暂无评论