フィルターのクリア

Difference Between saveas and print Commands

22 ビュー (過去 30 日間)
Milos
Milos 2011 年 7 月 18 日
Why are image dimensions different when using saveas and print commands? Figure size is set to 560x420. Command saveas(1,'sa_01','bmp') yields image correct in size. Command print(1,'-dbmp256','pr_01.bmp') yields image incorrect in size - 576x432.

採用された回答

Jan
Jan 2011 年 7 月 18 日
PRINT with the dbmp256 device use other coordinates than e.g. the dbmp device. Just set a breakpoint in PRINT and find the line, which changes the units to points and use the PaperPosition value as output size.
FigH = figure;
set(FigH, 'PaperUnits', 'points',
'PaperPosition', [18, 180, 560, 420]);
print(FigH, 'pr_01.bmp', '-dbmp256', '-r100')
This creates a 560 x 420 pixel bmp.
  1 件のコメント
Milos
Milos 2011 年 7 月 18 日
Thanks Jan! I never bothered checking _PaperUnits_ and _PaperPosition_.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 7 月 18 日
"Why" is something that many of us have stopped asking with regards to saveas() and print(). No offense intended to the fine folks at Mathworks, but the challenges associated with those functions have been around a long time, and I have not seen any indication that Mathworks has made updating them to be a priority.
If you want a routine that is much more reliable and which you can customize at need, please see Oliver's contribution export_fig
  1 件のコメント
Milos
Milos 2011 年 7 月 18 日
I use export_fig regularly for saving presentation/publication quality images. I came across this saveas/print conundrum while enabling users under Unix OS to save figures to BMP format (officially not supported as saveas compatible format). Jan's solution works like a charm. Sadly, it's a workaround since MathWorks suggest returning custom value of PaperUnit to default value.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by