Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

javascript - canvas的toDataURL()函数可能使用的数据类型是什么?(What are the possible data types for canvas' toDataURL() function?)

canvas.toDataURL(type, encoderOptions);

MDN 's description about the type parameter says the following:(MDN关于type参数的描述如下:)

type Optional(类型 可选)


A DOMString indicating the image format.(指示图像格式的DOMString 。) The default type is image/png .(默认类型为image / png 。)

I have yet to find what all the types are, as I'm trying to evaluate what is possible to use in different cases.(我还没有找到所有的类型,因为我正在尝试评估在不同情况下可以使用的类型。)

Edit: MSDN's article about toDataURL() doesn't really help either.(编辑: MSDN的有关toDataURL() 的文章也没有帮助。)


I know about the following:(我了解以下内容:)

  • image/png quality (encoder options) doesn't seem to influence output(image/png质量(编码器选项)似乎不影响输出)
  • image/jpeg quality (encoder options) influences output(image/jpeg质量(编码器选项)影响输出)
  • image/webp quality influences output.(image/webp质量会影响输出。) (Chrome-only according to MDN).((根据MDN,仅适用于Chrome)。)

But after looking around I can't seem to find a list of possible types and their encoder options... that's pretty much all I could find.(但是环顾四周之后,我似乎找不到可能的类型及其编码器选项的列表……这几乎是我所能找到的全部。)

What are the other possibilities?(还有其他可能性吗?)   ask by Jeff Noel translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Per the firefox source code , they seems to support:(根据firefox 源代码 ,它们似乎支持:)

  • png(png)
  • jpeg(jpeg)
  • ico(ico)
  • bmp(bmp)

Chrome per the source code , should support:(Chrome源代码 ,应支持:)

  • webp(网页)
  • png(png)
  • jpeg(jpeg)
  • bmp(bmp)

Internet explorer modern versions, should be alike to Firefox (crossing fingers).(Internet Explorer的现代版本应该类似于Firefox (但不多见)。)

If I need to vote the "per today" available options, I will go with: PNG, JPEG, and BMP(如果我需要对“每天”的可用选项进行投票,我将使用: PNG,JPEG和BMP)

Quality influences options:(质量影响选择:)

  • JPEG, quality percent, where 0 is 0%, 0.5 is 50% and 1 is 100%(JPEG,质量百分比,其中0为0%,0.5为50%和1为100%)
  • BMP, BPP, bytes per pixel (thanks to @apsillers for pointing out)(BMP,BPP,每像素字节(感谢@apsillers指出))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...