Canvas icon indicating copy to clipboard operation
Canvas copied to clipboard

8 is not a valid argument count for any overload.

Open nurbat opened this issue 4 years ago • 3 comments

изображение

изображение

nurbat avatar Mar 09 '21 13:03 nurbat

I'm pretty sure TexImage2DAsync is currently not functional. At least, if it is, I haven't been able to figure out how to use it. The only workaround I could find was to create and call a js function that gets the canvas and runs texImage2D.

function addTextureToCanvas(imgId) {
    canvas = document.getElementsByTagName("canvas");
    var gl = canvas[0].getContext("webgl");

    var image = document.getElementById(imgId);
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
    //gl.generateMipmap(gl.TEXTURE_2D);
}

I hope that helps.

JacobClinton avatar Apr 12 '21 10:04 JacobClinton

it is no longer relevant, but thanks to your sources.. I was able to write an image generation based on byte [] await _context.DrawImageAsync(imagePngBytes, ImageFormat.PNG, OffsetX, OffSetY, (int)maxX, (int)maxY);

nurbat avatar Apr 12 '21 11:04 nurbat

The border is missing, more information here.

Duplicate Issues

  • https://github.com/BlazorExtensions/Canvas/issues/65
  • https://github.com/BlazorExtensions/Canvas/issues/63
  • https://github.com/BlazorExtensions/Canvas/issues/60 (has PR)
  • https://github.com/BlazorExtensions/Canvas/issues/50

Sample

await context.TexImage2DAsync(Texture2DType.TEXTURE_2D, 0, PixelFormat.RGBA, data.Width, data.Height, PixelFormat.RGBA, PixelType.UNSIGNED_BYTE, data.Pixels);
glpMipmapViewer.prototype.texImage2D = function(original, args) {
  if (!this.textureExists(this.activeTexture)) {
    return;
  }

  if(args.length == 9 && args[8] == this.mipmapPixels && args[1] == this.currentLevel) {
    return;
  }
  // figure out which function type it's using
  var textureObj = this.textureUsage[this.activeTexture.__uuid];
  var level = args[1];
  if (args.length == 6) {
    textureObj.imageLevels.splice(level, 0, {
      functionType : this.texImage2DFcnType.TEX_IMAGE_2D_6,
      arguments : args });
  } else if (args.length == 9) {
    textureObj.imageLevels.splice(level, 0, {
      functionType : this.texImage2DFcnType.TEX_IMAGE_2D_9,
      arguments : args });
  } else {
    console.error("texImage2D function args is not valid");
    return;
  }

  textureObj.fcnUsages.push( { fcn : original, args: args } );
}

erictuvesson avatar Jun 24 '21 13:06 erictuvesson