使用Html2Image提高图像的质量和大小

时间:2019-05-01 07:33:04

标签: javascript asp.net image canvas html2canvas

当我尝试使用Html2Image将div转换为图像时,图像质量将非常差且不清楚。所以我想提高图像的质量

我在互联网上进行了几次搜索以找到解决该问题的方法,然后尝试在toDataURL中给出其最大质量大小,该大小在0..1之间,但是仍然没有很好的质量。

#include <fcntl.h>
#include <unistd.h>
#include <poll.h>

int main(int argc, char *argv[])
{
    int timeout_ms = 5000;
    char input_dev[] = "/dev/input/event17\0";
    int st;
    int ret;
    struct pollfd fds[1];

    fds[0].fd = open(input_dev, O_RDONLY|O_NONBLOCK);

    if(fds[0].fd<0)
    {
        printf("error unable open for reading '%s'\n",input_dev);
        return(0);
    }

    const int input_size = 4096;
    unsigned char input_data[input_size];
    memset(input_data,0,input_size);

    fds[0].events = POLLIN;

    int exit_on_key_press_count = 10;

    while(true)
    {
        ret = poll(fds, 1, timeout_ms);

        if(ret>0)
        {
            if(fds[0].revents)
            {
                ssize_t r = read(fds[0].fd,input_data,input_size);

                if(r<0)
                {
                    printf("error %d\n",(int)r);
                    break;
                }
                else
                {
                    printf("total bytes read %d/%d\n",(int)r,input_size);

                    for(int i = 0; i<r;i++)
                    {
                        printf("%02X ",(unsigned char)input_data[i]);
                    }
                    printf("\n");
                    memset(input_data,0,input_size);

                    exit_on_key_press_count--;
                    if(exit_on_key_press_count<1)
                        break;
                }
            }
            else
            {
                printf("error\n");
            }
        }
        else
        {
            printf("timeout\n");
        }
    }

    close(fds[0].fd);
    return 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div id="html-content-holder" style="background-color: #F0F0F1; color: #00cc65; width: 400px; height: 250px;
        padding-left: 25px; padding-top: 10px;">
          <div class="col-lg-6 col-md-10 col-sm-12 portfolio-item" style="margin-left: auto; margin-right: auto">
                <div class="card">
                    <div class="card-body">
                        <asp:Image ID="Image1" ImageUrl="X7s53u.jpg" class="col-lg-3" runat="server" Width="100" Height="150" Style="margin-top: 10px; float: left; border: 1px solid #808080" />
                        <div style="float:right;width:70%">
                            <div style="margin-bottom:4px; color:red;text-align: right;">
                                <img src="Logo.png" style="height:50px; width:50px; float: right;" />
                                موسسه <br />
                                <span style="font-size:9px">Fellowship Fund For Employees of 000000 </span>
                            </div>
                            <div style="background-color:red;color:white; padding:2px 10px 2px 10px; margin-top:4px">
                                <b style="text-align: right;">بطاقة عضوية</b>
                                <b style="float: left;">Membership Card</b>
                            </div>
                            <div></div>
                        </div>
                    </div>
                </div>
            </div>
    </div>

    <input id="btn-Preview-Image" type="button" value="Preview" />
    <a id="btn-Convert-Html2Image" href="#">Download</a>

    <br />
    <h3>Preview :</h3>
    <div id="previewImage">
    </div>

我想增加图像的质量和尺寸,该怎么办?

0 个答案:

没有答案