Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android DroidText图像只有在我将其转换为JPEG时才有效_Android_Pdf - Fatal编程技术网

Android DroidText图像只有在我将其转换为JPEG时才有效

Android DroidText图像只有在我将其转换为JPEG时才有效,android,pdf,Android,Pdf,在我的应用程序中,我正在制作pdf。这个pdf需要我生成的位图。此代码适用于: document.open(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmap.compress(Bitmap.CompressFormat.JPEG , 100 , stream); Image jpg = Image.getInsta

在我的应用程序中,我正在制作pdf。这个pdf需要我生成的位图。此代码适用于:

        document.open();
        ByteArrayOutputStream stream = new ByteArrayOutputStream();

        bmap.compress(Bitmap.CompressFormat.JPEG ,
                100 , stream);
        Image jpg = Image.getInstance(stream.toByteArray());
        jpg.scalePercent(71, 71);
        document.add(jpg);
不幸的是,转换成JPEG会损失很多质量。我尝试将其转换为PNG,如下所示:

        document.open();
        ByteArrayOutputStream stream = new ByteArrayOutputStream();

        bmap.compress(Bitmap.CompressFormat.PNG ,
                100 , stream);
        Image jpg = Image.getInstance(stream.toByteArray());
        jpg.scalePercent(71, 71);
        document.add(jpg);

但这只会生成一个无法打开的PDF。代码似乎运行得很好,我使用了调试器,流中似乎有一个图像。发生了什么事?

71、71代表什么?我必须按这个比例缩放图像,以使其合适。它并不代表什么。我知道我不应该用那个样的随机常数,但你们知道它是怎么回事…x和y比例百分比