Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,10 @@ func (f *File) drawingsWriter() {
})
}

// drawingResize calculate the height and width after resizing.
func (f *File) drawingResize(sheet, cell string, width, height float64, opts *GraphicOptions) (w, h, c, r int, err error) {
// GetCellPixelsWithCoordinates returns the pixel dimensions of a specified cell within a given sheet,
// accounting for merged cells. This function calculates the total pixel width and height
// for individual or merged cells and provides the column and row index of the cell.
func (f *File) GetCellPixelsWithCoordinates(sheet, cell string) (cellWidth, cellHeight, c, r int, err error) {
var mergeCells []MergeCell
mergeCells, err = f.GetMergeCells(sheet)
if err != nil {
Expand All @@ -752,7 +754,7 @@ func (f *File) drawingResize(sheet, cell string, width, height float64, opts *Gr
if c, r, err = CellNameToCoordinates(cell); err != nil {
return
}
cellWidth, cellHeight := f.getColWidth(sheet, c), f.getRowHeight(sheet, r)
cellWidth, cellHeight = f.getColWidth(sheet, c), f.getRowHeight(sheet, r)
for _, mergeCell := range mergeCells {
if inMergeCell {
continue
Expand All @@ -772,6 +774,12 @@ func (f *File) drawingResize(sheet, cell string, width, height float64, opts *Gr
cellHeight += f.getRowHeight(sheet, row)
}
}
return
}

// drawingResize calculate the height and width after resizing.
func (f *File) drawingResize(sheet, cell string, width, height float64, opts *GraphicOptions) (w, h, c, r int, err error) {
cellWidth, cellHeight, c, r, err := f.GetCellPixelsWithCoordinates(sheet, cell)
if float64(cellWidth) < width || float64(cellHeight) < height {
aspWidth := float64(cellWidth) / width
aspHeight := float64(cellHeight) / height
Expand Down