mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
add protected code when rect.width or rect.height is 0
This commit is contained in:
@@ -701,6 +701,8 @@ game.once(game.EVENT_RENDERER_INITED, function () {
|
||||
var textureImage = this._htmlElementObj;
|
||||
if(!rect)
|
||||
rect = cc.rect(0, 0, textureImage.width, textureImage.height);
|
||||
if(!rect.width || !rect.height)
|
||||
return;
|
||||
|
||||
canvas.width = rect.width;
|
||||
canvas.height = rect.height;
|
||||
@@ -737,6 +739,9 @@ game.once(game.EVENT_RENDERER_INITED, function () {
|
||||
if(!rect)
|
||||
rect = cc.rect(0, 0, textureImage.width, textureImage.height);
|
||||
|
||||
if(!rect.width || !rect.height)
|
||||
return;
|
||||
|
||||
canvas.width = rect.width;
|
||||
canvas.height = rect.height;
|
||||
|
||||
@@ -748,9 +753,6 @@ game.once(game.EVENT_RENDERER_INITED, function () {
|
||||
0, 0, rect.width, rect.height
|
||||
);
|
||||
|
||||
if(onlyCanvas)
|
||||
return canvas;
|
||||
|
||||
var imageData = context.getImageData(0,0,canvas.width, canvas.height);
|
||||
var data = imageData.data;
|
||||
r = r/255;
|
||||
@@ -764,6 +766,9 @@ game.once(game.EVENT_RENDERER_INITED, function () {
|
||||
|
||||
context.putImageData(imageData, 0, 0);
|
||||
|
||||
if(onlyCanvas)
|
||||
return canvas;
|
||||
|
||||
var newTexture = new Texture2D();
|
||||
newTexture.initWithElement(canvas);
|
||||
newTexture.handleLoadedTexture();
|
||||
|
||||
Reference in New Issue
Block a user