为什么iOS无法显示我的画布?

时间:2018-06-25 02:13:04

标签: javascript ios html5 css3 html5-canvas

有几个类似的问题,但没有关于我的仅限iOS的问题。

此代码可在台式机或笔记本电脑以及非iOS移动设备上完美运行。它获取已编辑图像的缩略图样本,并在新画布中以完整尺寸显示它。在iOS上,我只看到画布应该放在的空白屏幕。

function click5()
{       
    document.getElementById("preview").style = "visibility:visible;"; 
    document.getElementById("cPreviewCaption").style = "font-size:90%; font-weight:550; text-align:center; color:#FFFFFF; padding-top:6px;";  

    // Apply change to preview image which will open beneath thumbnails 
    var cP = document.getElementById("cPreview"); 
    var contextP = cP.getContext("2d");

    var cO = document.getElementById("cOriginal"); 
    var contextO = cO.getContext("2d");

    var imgData = contextO.getImageData(0,0,cO.width,cO.height);
    var data = imgData.data;



    //read full size image 
    //similar image read/write code works fine in another image filter so this does not appear to be the issue 
    for (i = 0; i < data.length; i += 4)
    {                       
        red[i] = imgData.data[i];
        green[i] = imgData.data[i+1];
        blue[i] = imgData.data[i+2];
        alpha[i] = imgData.data[i+3];
    }

    //set adjustments represented by user interaction with thumbnails 
    for (i = 0; i < data.length; i += 4)
    {                       
        red[i] = red[i] + finalRedAdjust;
        if (red[i] < 0) red[i] = 0;  
        if (red[i] > 255) red[i] = 255; 
        green[i] = green[i] + finalGreenAdjust;
        if (green[i] < 0) green[i] = 0; 
        if (green[i] > 255) green[i] = 255; 
    }

    //write full size image with adjustments to memory  
    for (i = 0; i < data.length; i += 4)    
    {
        imgData.data[i] = red[i];
        imgData.data[i+1] = green[i];
        imgData.data[i+2] = blue[i]; 
        imgData.data[i+3] = alpha[i];   
    }               

    //write image in memory to file 
    contextP.putImageData(imgData, 0, 0);

    //add borders for canvases. 
    document.getElementById('cOriginal').style = "border-style:solid; border-color: #C0C0C0 #C0C0C0 #606060 #606060; visibility:hidden; display:none;"; 
    document.getElementById('cPreview').style = "border-style:solid; border-color: #C0C0C0 #C0C0C0 #606060 #606060; visibility:visible; display:block;"; 

    //Scroll page to preview image 
    location.hash = "null"; 
    location.hash = "previewAnchor";  
}
// End Table Click Event Functions

我尝试使用很小的图像进行此操作,因此尺寸和文件大小似乎不是问题。

谢谢

0 个答案:

没有答案