Android。如何在保存時創建圖像是A4格式的大小。圖像將是矩形。我正在使用Canvas在矩形上創建圖像。也許更簡單的創建一個PDF文件?如何在保存時創建圖像的尺寸爲A4尺寸
回答
我不是真正確保你的問題,但這裏是如何:
看到這裏使用Android縮放傳入A4位圖到一個不同的大小
http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap
然後看看:drawBitmap(Bitmap bitmap,Rect src,RectF dst,Paint paint)
以A4大小的圖像(297x210mm)並將其縮放到畫布中。
您可以使用canvas.context.drawImage()方法獲取全尺寸的A4圖像並將其縮小以適合您的畫布。下面的代碼顯示瞭如何根據源圖像自動調整畫布到A4比例的大小。
這裏是代碼和一個小提琴:http://jsfiddle.net/m1erickson/FAbBm/
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="css/reset.css" /> <!-- reset css -->
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<style>
body{ background-color: ivory; }
canvas{border:1px solid red;}
</style>
<script>
$(function(){
var canvas=document.getElementById("canvas");
ctx=canvas.getContext("2d");
var ScaleDown=.25;
var A4=new Image();
A4.onload=function(){
canvas.width=A4.width*ScaleDown;
canvas.height=A4.height*ScaleDown;
ctx.drawImage(A4,0,0,A4.width,A4.height,0,0,canvas.width,canvas.height);
}
A4.src="http://4.bp.blogspot.com/-GKxNKmWgq8s/UJ8zxWLGz5I/AAAAAAAAAgs/fW-MFuw9BFM/s1600/rieger-tuning-audi-a4.jpg";
}); // end $(function(){});
</script>
</head>
<body>
<canvas id="canvas" width=300 height=300></canvas>
</body>
</html>
你確實知道沒有HTML標籤?這是一個機器人問題... – WarrenFaith 2013-03-07 19:02:20
是的,它*可能*是「我的壞」,因爲我看到「畫布」......但承認它,OP的問題很難理解;) - 我將編輯我的回答也指向了縮放位圖的android方法:drawBitmap(bitmap,sourceRectangle,destinationRectangle,paintDefinitions)。 – markE 2013-03-07 19:21:46
請編輯問題併爲android添加解決方案 – 2016-08-16 04:55:11
- 1. 使用原始尺寸的圖像創建A4尺寸紙張的PDF
- 2. 保存時圖像尺寸增加
- 3. 如何打印尺寸以a4尺寸打印出來
- 4. 尺寸圖像的尺寸1600 * 1200
- 5. 圖像尺寸,
- 6. 圖像尺寸
- 7. 爲不同尺寸的圖像創建固定的縮略圖尺寸
- 8. 尺寸圖像以適合WebView尺寸
- 9. 屏幕尺寸到圖像尺寸
- 10. 拉伸格到A4尺寸
- 11. FPDF A4尺寸不打印
- 12. 創建汽車在C#尺寸圖像
- 13. Amalgamate A6尺寸頁在A4尺寸頁面上打印
- 14. 在小尺寸窗口中保存大尺寸圖片
- 15. itext如何重新調整A3尺寸的PDF格式,內容爲A4尺寸
- 16. 使用箱尺寸:「邊界框」,並保持圖像尺寸
- 17. Carrierwave圖像尺寸
- 18. PHP圖像尺寸
- 19. ImageView圖像尺寸
- 20. TTTableItem圖像尺寸
- 21. UIViewcontroller圖像尺寸
- 22. FPDF圖像尺寸
- 23. 將JPanel設置爲A4尺寸
- 24. WP7如何適應網格尺寸圖像尺寸
- 25. 如何設置UINavigation尺寸以適合背景圖像尺寸?
- 26. PHP GD圖像尺寸返回錯誤圖像尺寸
- 27. html使圖像按鈕尺寸等於圖像尺寸
- 28. 當屏幕尺寸減小時自動調整圖像尺寸
- 29. 在HTML中重複A4尺寸樣式
- 30. 在php中動態測量A4尺寸
很抱歉,但什麼?你的問題幾乎無法理解。 – WarrenFaith 2013-03-06 17:35:58
如何使用Canvas在出口創建格式爲210х297的圖像?對不起英文不好的 – 2013-03-06 17:59:11
谷歌的截圖教程。 – WarrenFaith 2013-03-06 18:27:41