Android Canvas - 以80%的质量压缩图像,但保留叠加文本100%

时间:2016-03-07 10:18:00

标签: android image canvas bitmap compression

我需要在图像上写文字并将其保存为jpg格式。我必须将图像压缩到80%质量以减少文件大小。图像本身看起来不错,但上面的文字看起来并不吸引人。

有没有办法将图像部分缩小到80但是在合并时将文本部分保持为100?提前谢谢。

if Function == '1':
    Amount = int (input ('How many Numbers do you need to use (9 numbers max and 2 numbers min):'))
    if Amount == '2':
        NumberOne = int (input ('Enter The First Number: '))
        print ''
        NumberTwo = int (input ('Enter The Second Number: '))
        Answer = NumberOne + NumberTwo
        def print_slow(str):
            for letter in str:
                sys.stdout.write(letter)
                sys.stdout.flush()
                time.sleep(0.4)

        print_slow(str (NumberOne) + ' + ' + str (NumberTwo) + ' = ' + str (Answer))

    elif Amount == '3':
        NumberOne = int (input ('Enter The First Number: '))
        print ''
        NumberTwo = int (input ('Enter The Second Number: '))
        print ''
        Numberthree = int (input ('Enter The Third Number: '))
        Answer = NumberOne + NumberTwo + Numberthree
        def print_slow(str):
            for letter in str:
                sys.stdout.write(letter)
                sys.stdout.flush()
                time.sleep(0.4)

        print_slow(str (NumberOne) + ' + ' + str (NumberTwo) + ' + ' + str (NumberThree) + ' = ' + str (Answer))     

1 个答案:

答案 0 :(得分:0)

不,没有。 compress函数对文本一无所知。它只看到像素。它只能以1个质量级别压缩整个图像。如果图像质量不够好,请提高质量或切换到无损编码。