Want to join? Log In or Join Now in seconds. English (United States)

CREATE A NEW ACCOUNT

{{registerModel.Error}}

Log In

/content/images/forum.png

Feedbacks

Get help from the knowledgeable Reddah Community and official Reddah Support!
/content/images/ambassador.png

Discuss on AD

A place for discussing the ads that reddah is currently running.
/content/images/contact_us.png

Contact Us

Get in touch with an Reddah Support technician. We are ready and willing to help you!
26

var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), img = new Image(), effectEl = document.getElementById("effect"), settings = { radius: 4, intensity: 25, ApplyFilter: function() { doOilPaintEffect(); } } img.addEventListener('load', function() { // reduced the size by half for pen and performance. canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }); function choosePhoto(){ alert(1) window["reddahApi"].album().then(data=>{ alert(data) img.src=data; doOilPaintEffect(); }) } img.crossOrigin = "Anonymous"; img.src = "assets/500/501.jpeg"; //"https://wow.techbrood.com/uploads/161001/normal2.jpg"; //var gui = new dat.GUI(); //gui.add(settings, 'intensity'); //gui.add(settings, 'radius'); //gui.add(settings, 'ApplyFilter'); function doOilPaintEffect() { oilPaintEffect(canvas, settings.radius, settings.intensity); } function oilPaintEffect(canvas, radius, intensity) { var width = canvas.width, height = canvas.height, imgData = ctx.getImageData(0, 0, width, height), pixData = imgData.data, // change to createElement getting added element just for the demo destCanvas = document.getElementById("dest-canvas"), dCtx = destCanvas.getContext("2d"), pixelIntensityCount = []; destCanvas.width = width; destCanvas.height = height; var destImageData = dCtx.createImageData(width, height), destPixData = destImageData.data, intensityLUT = [], rgbLUT = []; for (var y = 0; y < height; y++) { intensityLUT[y] = []; rgbLUT[y] = []; for (var x = 0; x < width; x++) { var idx = (y * width + x) * 4, r = pixData[idx], g = pixData[idx + 1], b = pixData[idx + 2], avg = (r + g + b) / 3; intensityLUT[y][x] = Math.round((avg * intensity) / 255); rgbLUT[y][x] = { r: r, g: g, b: b }; } } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixelIntensityCount = []; // Find intensities of nearest pixels within radius. for (var yy = -radius; yy <= radius; yy++) { for (var xx = -radius; xx <= radius; xx++) { if (y + yy > 0 && y + yy < height && x + xx > 0 && x + xx < width) { var intensityVal = intensityLUT[y + yy][x + xx]; if (!pixelIntensityCount[intensityVal]) { pixelIntensityCount[intensityVal] = { val: 1, r: rgbLUT[y + yy][x + xx].r, g: rgbLUT[y + yy][x + xx].g, b: rgbLUT[y + yy][x + xx].b } } else { pixelIntensityCount[intensityVal].val++; pixelIntensityCount[intensityVal].r += rgbLUT[y + yy][x + xx].r; pixelIntensityCount[intensityVal].g += rgbLUT[y + yy][x + xx].g; pixelIntensityCount[intensityVal].b += rgbLUT[y + yy][x + xx].b; } } } } pixelIntensityCount.sort(function(a, b) { return b.val - a.val; }); var curMax = pixelIntensityCount[0].val, dIdx = (y * width + x) * 4; destPixData[dIdx] = ~~(pixelIntensityCount[0].r / curMax); destPixData[dIdx + 1] = ~~(pixelIntensityCount[0].g / curMax); destPixData[dIdx + 2] = ~~(pixelIntensityCount[0].b / curMax); destPixData[dIdx + 3] = 255; } } // change this to ctx to instead put the data on the original canvas dCtx.putImageData(destImageData, 0, 0); } window["reddahApi"].loadCompleted()

body { text-align: center; background: #ececec; font-family: Tahoma, Geneva, sans-serif } section { display: inline-block } canvas { border: 1px solid #000 }
submitted 6 years ago ago by 1b54d14be50240948fc53b199a461f52
picture

Original

仿PS油画滤镜特效


28
picture

Theresa May suffers another humiliating Brexit defeat

British Prime Minister Theresa May was dealt another humiliating blow Thursday as lawmakers voted against the latest incarnation of her Brexit plan.
world submitted 7 years ago ago by b8c40ad899c64f9a88cfca87d90e5c34
picture

While the vote was merely symbolic, Parliament's refusal to reaffirm its support for May's approach to negotiations with the European Union represented another setback for the government as it attempts to reopen the terms of its Brexit deal with the EU.

Lawmakers voted 303 to 258 against the government's motion, which included an amendment on renegotiating the Irish backstop -- a contentious part of the deal -- along with a nonbinding amendment to prevent a no-deal Brexit.

A group of hard-line Brexiteers in May's Conservative party abstained from the vote on Thursday, unwilling to back a motion that aimed to block Britain from crashing out of Europe on March 29 without a deal.

May has previously refused to rule out a no-deal Brexit, even though a majority of lawmakers say it will plunge the UK into chaos. That is with the exception of Brexiteers, who maintain that keeping it on the table is a necessary negotiating tactic with the EU.

There is growing frustration in Brussels with May, who is seen as a less reliable negotiating partner by the day.

"She's trying appeasement but it's just not working. You would think there should be a moment she has to sacrifice party unity to ensure safe landing for her country. But [I] doubt she will, hoping eventually the EU moves in the end," one EU diplomat told CNN.

Ireland's Deputy Prime Minister Simon Coveney said Thursday night that it was Britain's responsibility to break the current impasse -- not the EU.

"We should say very firmly that the responsibility to come up with ways of solving the current impasse lies where the impasse is, which London -- not Brussels, not Dublin, not Belfast or anywhere else," Coveney told the Irish Parliamentary Foreign Affairs Committee.

30
picture

UK lawmakers: Facebook 'intentionally and knowingly' violated data privacy laws

UK lawmakers have accused Facebook of violating data privacy and competition laws in a report on social media disinformation that also says CEO Mark Zuckerberg showed "contempt" toward parliament
world,facebook submitted 7 years ago ago by b8c40ad899c64f9a88cfca87d90e5c34
picture

UK lawmakers have accused Facebook of violating data privacy and competition laws in a report on social media disinformation that also says CEO Mark Zuckerberg showed "contempt" toward parliament by not appearing before them.

The UK Digital, Culture, Media and Sport Committee said in a report published Monday that a trove of internal Facebook emails it reviewed demonstrated that the social media platform had "intentionally and knowingly" violated both data privacy and competition laws.

According to the committee, the documents show that Facebook was "willing to override its users' privacy settings in order to transfer data" to app developers. The lawmakers also claim the documents show the social network was able to "starve" some developers of data and force them out of business.

"Companies like Facebook should not be allowed to behave like 'digital gangsters' in the online world, considering themselves to be ahead of and beyond the law," the report said.

In response to the report, Facebook said it had not breached data protection or competition laws. Karim Palant, Facebook's UK public policy manager, said in a statement that the company "supports effective privacy legislation" and is also open to "meaningful regulation."

Overhaul needed

While Facebook was a major focus of the report, the Digital, Culture, Media and Sport Committee made several recommendations on how to combat fake news and disinformation.

The committee said:

  • Social media platforms should be subject to a compulsory code of ethics.
  • An independent UK regulator should monitor tech companies, and be able to launch legal proceedings against them.
  • UK antitrust regulators should conduct a "comprehensive audit" of the advertising market on social media.
  • UK regulators should investigate whether Facebook has been involved in anti-competitive practices.
  • The government should examine recent elections for evidence of voter manipulation.

The committee's investigation lasted 18 months and featured nearly two dozen oral evidence sessions, including a special hearing in Washington, D.C. and an "international grand committee" attended by representatives of nine countries. The final report ran to over 100 pages.

"The big tech companies must not be allowed to expand exponentially, without constraint or proper regulatory oversight," the report stated. "Only governments and the law are powerful enough to contain them."

Target: Facebook

The report harshly criticized Facebook and Zuckerberg, who repeatedly refused to appear before the committee last year despite numerous requests.

"The management structure of Facebook is opaque to those outside the business and this seemed to be designed to conceal knowledge of and responsibility for specific decisions," the report said. "Facebook used the strategy of sending witnesses who they said were the most appropriate representatives, yet had not been properly briefed on crucial issues, and could not or chose not to answer many of our questions."

The report's authors said they had "no doubt that this strategy was deliberate."

Facebook's response

Palant, the Facebook public policy manager, said that the company shares the committee's "concerns about false news and election integrity" and that it had made "a significant contribution to their investigation" by answering more than 700 questions.

Palant also highlighted the "substantial changes" to political advertising standards the company has undertaken.

"No other channel for political advertising is as transparent and offers the tools that we do," said Palant. "We have tripled the size of the team working to detect and protect users from bad content to 30,000 people and invested heavily in machine learning, artificial intelligence and computer vision technology to help prevent this type of abuse."

32

var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), img = new Image(), effectEl = document.getElementById("effect"), settings = { radius: 4, intensity: 25, ApplyFilter: function() { doOilPaintEffect(); } } img.addEventListener('load', function() { // reduced the size by half for pen and performance. canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }); function choosePhoto(){ window["reddahApi"].album().then(data=>{ alert(data) data=data.replace("file://",""); img.src=data; doOilPaintEffect(); alert(2) }) } img.crossOrigin = "Anonymous"; img.src = "assets/500/501.jpeg"; //"https://wow.techbrood.com/uploads/161001/normal2.jpg"; //var gui = new dat.GUI(); //gui.add(settings, 'intensity'); //gui.add(settings, 'radius'); //gui.add(settings, 'ApplyFilter'); function doOilPaintEffect() { oilPaintEffect(canvas, settings.radius, settings.intensity); } function oilPaintEffect(canvas, radius, intensity) { var width = canvas.width, height = canvas.height, imgData = ctx.getImageData(0, 0, width, height), pixData = imgData.data, // change to createElement getting added element just for the demo destCanvas = document.getElementById("dest-canvas"), dCtx = destCanvas.getContext("2d"), pixelIntensityCount = []; destCanvas.width = width; destCanvas.height = height; var destImageData = dCtx.createImageData(width, height), destPixData = destImageData.data, intensityLUT = [], rgbLUT = []; for (var y = 0; y < height; y++) { intensityLUT[y] = []; rgbLUT[y] = []; for (var x = 0; x < width; x++) { var idx = (y * width + x) * 4, r = pixData[idx], g = pixData[idx + 1], b = pixData[idx + 2], avg = (r + g + b) / 3; intensityLUT[y][x] = Math.round((avg * intensity) / 255); rgbLUT[y][x] = { r: r, g: g, b: b }; } } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixelIntensityCount = []; // Find intensities of nearest pixels within radius. for (var yy = -radius; yy <= radius; yy++) { for (var xx = -radius; xx <= radius; xx++) { if (y + yy > 0 && y + yy < height && x + xx > 0 && x + xx < width) { var intensityVal = intensityLUT[y + yy][x + xx]; if (!pixelIntensityCount[intensityVal]) { pixelIntensityCount[intensityVal] = { val: 1, r: rgbLUT[y + yy][x + xx].r, g: rgbLUT[y + yy][x + xx].g, b: rgbLUT[y + yy][x + xx].b } } else { pixelIntensityCount[intensityVal].val++; pixelIntensityCount[intensityVal].r += rgbLUT[y + yy][x + xx].r; pixelIntensityCount[intensityVal].g += rgbLUT[y + yy][x + xx].g; pixelIntensityCount[intensityVal].b += rgbLUT[y + yy][x + xx].b; } } } } pixelIntensityCount.sort(function(a, b) { return b.val - a.val; }); var curMax = pixelIntensityCount[0].val, dIdx = (y * width + x) * 4; destPixData[dIdx] = ~~(pixelIntensityCount[0].r / curMax); destPixData[dIdx + 1] = ~~(pixelIntensityCount[0].g / curMax); destPixData[dIdx + 2] = ~~(pixelIntensityCount[0].b / curMax); destPixData[dIdx + 3] = 255; } } // change this to ctx to instead put the data on the original canvas dCtx.putImageData(destImageData, 0, 0); } window["reddahApi"].loadCompleted()

body { text-align: center; background: #ececec; font-family: Tahoma, Geneva, sans-serif } section { display: inline-block } canvas { border: 1px solid #000 }
submitted 6 years ago ago by 1b54d14be50240948fc53b199a461f52
picture

Original

仿PS油画滤镜特效


34

var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), img = new Image(), effectEl = document.getElementById("effect"), settings = { radius: 4, intensity: 25, ApplyFilter: function() { doOilPaintEffect(); } } img.addEventListener('load', function() { // reduced the size by half for pen and performance. canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }); function choosePhoto(){ window["reddahApi"].album().then(data=>{ alert(data) data=data.replace("file://",""); img.src=data; canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); alert(2) }) } img.crossOrigin = "Anonymous"; img.src = "assets/500/501.jpeg"; //"https://wow.techbrood.com/uploads/161001/normal2.jpg"; //var gui = new dat.GUI(); //gui.add(settings, 'intensity'); //gui.add(settings, 'radius'); //gui.add(settings, 'ApplyFilter'); function doOilPaintEffect() { oilPaintEffect(canvas, settings.radius, settings.intensity); } function oilPaintEffect(canvas, radius, intensity) { var width = canvas.width, height = canvas.height, imgData = ctx.getImageData(0, 0, width, height), pixData = imgData.data, // change to createElement getting added element just for the demo destCanvas = document.getElementById("dest-canvas"), dCtx = destCanvas.getContext("2d"), pixelIntensityCount = []; destCanvas.width = width; destCanvas.height = height; var destImageData = dCtx.createImageData(width, height), destPixData = destImageData.data, intensityLUT = [], rgbLUT = []; for (var y = 0; y < height; y++) { intensityLUT[y] = []; rgbLUT[y] = []; for (var x = 0; x < width; x++) { var idx = (y * width + x) * 4, r = pixData[idx], g = pixData[idx + 1], b = pixData[idx + 2], avg = (r + g + b) / 3; intensityLUT[y][x] = Math.round((avg * intensity) / 255); rgbLUT[y][x] = { r: r, g: g, b: b }; } } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixelIntensityCount = []; // Find intensities of nearest pixels within radius. for (var yy = -radius; yy <= radius; yy++) { for (var xx = -radius; xx <= radius; xx++) { if (y + yy > 0 && y + yy < height && x + xx > 0 && x + xx < width) { var intensityVal = intensityLUT[y + yy][x + xx]; if (!pixelIntensityCount[intensityVal]) { pixelIntensityCount[intensityVal] = { val: 1, r: rgbLUT[y + yy][x + xx].r, g: rgbLUT[y + yy][x + xx].g, b: rgbLUT[y + yy][x + xx].b } } else { pixelIntensityCount[intensityVal].val++; pixelIntensityCount[intensityVal].r += rgbLUT[y + yy][x + xx].r; pixelIntensityCount[intensityVal].g += rgbLUT[y + yy][x + xx].g; pixelIntensityCount[intensityVal].b += rgbLUT[y + yy][x + xx].b; } } } } pixelIntensityCount.sort(function(a, b) { return b.val - a.val; }); var curMax = pixelIntensityCount[0].val, dIdx = (y * width + x) * 4; destPixData[dIdx] = ~~(pixelIntensityCount[0].r / curMax); destPixData[dIdx + 1] = ~~(pixelIntensityCount[0].g / curMax); destPixData[dIdx + 2] = ~~(pixelIntensityCount[0].b / curMax); destPixData[dIdx + 3] = 255; } } // change this to ctx to instead put the data on the original canvas dCtx.putImageData(destImageData, 0, 0); } window["reddahApi"].loadCompleted()

body { text-align: center; background: #ececec; font-family: Tahoma, Geneva, sans-serif } section { display: inline-block } canvas { border: 1px solid #000 }
submitted 6 years ago ago by 1b54d14be50240948fc53b199a461f52
picture

Original

仿PS油画滤镜特效


37

var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), img = new Image(), effectEl = document.getElementById("effect"), settings = { radius: 4, intensity: 25, ApplyFilter: function() { doOilPaintEffect(); } } img.addEventListener('load', function() { // reduced the size by half for pen and performance. canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }); function choosePhoto(){ window["reddahApi"].album().then(data=>{ img.src=data; canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); alert(3) }) } img.crossOrigin = "Anonymous"; img.src = "assets/500/501.jpeg"; //"https://wow.techbrood.com/uploads/161001/normal2.jpg"; //var gui = new dat.GUI(); //gui.add(settings, 'intensity'); //gui.add(settings, 'radius'); //gui.add(settings, 'ApplyFilter'); function doOilPaintEffect() { oilPaintEffect(canvas, settings.radius, settings.intensity); } function oilPaintEffect(canvas, radius, intensity) { var width = canvas.width, height = canvas.height, imgData = ctx.getImageData(0, 0, width, height), pixData = imgData.data, // change to createElement getting added element just for the demo destCanvas = document.getElementById("dest-canvas"), dCtx = destCanvas.getContext("2d"), pixelIntensityCount = []; destCanvas.width = width; destCanvas.height = height; var destImageData = dCtx.createImageData(width, height), destPixData = destImageData.data, intensityLUT = [], rgbLUT = []; for (var y = 0; y < height; y++) { intensityLUT[y] = []; rgbLUT[y] = []; for (var x = 0; x < width; x++) { var idx = (y * width + x) * 4, r = pixData[idx], g = pixData[idx + 1], b = pixData[idx + 2], avg = (r + g + b) / 3; intensityLUT[y][x] = Math.round((avg * intensity) / 255); rgbLUT[y][x] = { r: r, g: g, b: b }; } } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixelIntensityCount = []; // Find intensities of nearest pixels within radius. for (var yy = -radius; yy <= radius; yy++) { for (var xx = -radius; xx <= radius; xx++) { if (y + yy > 0 && y + yy < height && x + xx > 0 && x + xx < width) { var intensityVal = intensityLUT[y + yy][x + xx]; if (!pixelIntensityCount[intensityVal]) { pixelIntensityCount[intensityVal] = { val: 1, r: rgbLUT[y + yy][x + xx].r, g: rgbLUT[y + yy][x + xx].g, b: rgbLUT[y + yy][x + xx].b } } else { pixelIntensityCount[intensityVal].val++; pixelIntensityCount[intensityVal].r += rgbLUT[y + yy][x + xx].r; pixelIntensityCount[intensityVal].g += rgbLUT[y + yy][x + xx].g; pixelIntensityCount[intensityVal].b += rgbLUT[y + yy][x + xx].b; } } } } pixelIntensityCount.sort(function(a, b) { return b.val - a.val; }); var curMax = pixelIntensityCount[0].val, dIdx = (y * width + x) * 4; destPixData[dIdx] = ~~(pixelIntensityCount[0].r / curMax); destPixData[dIdx + 1] = ~~(pixelIntensityCount[0].g / curMax); destPixData[dIdx + 2] = ~~(pixelIntensityCount[0].b / curMax); destPixData[dIdx + 3] = 255; } } // change this to ctx to instead put the data on the original canvas dCtx.putImageData(destImageData, 0, 0); } window["reddahApi"].loadCompleted()

body { text-align: center; background: #ececec; font-family: Tahoma, Geneva, sans-serif } section { display: inline-block } canvas { border: 1px solid #000 }
submitted 6 years ago ago by 1b54d14be50240948fc53b199a461f52
picture

Original

仿PS油画滤镜特效


38

var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), img = new Image(), effectEl = document.getElementById("effect"), settings = { radius: 4, intensity: 25, ApplyFilter: function() { doOilPaintEffect(); } } img.addEventListener('load', function() { // reduced the size by half for pen and performance. canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }); function choosePhoto(){ window["reddahApi"].album().then(data=>{ alert(data) img.src=data.replace("file:///","http://localhost:8080/_app_file_"); alert(img.src) alert(3) canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); alert(3) }) } img.crossOrigin = "Anonymous"; img.src = "assets/500/501.jpeg"; //"https://wow.techbrood.com/uploads/161001/normal2.jpg"; //var gui = new dat.GUI(); //gui.add(settings, 'intensity'); //gui.add(settings, 'radius'); //gui.add(settings, 'ApplyFilter'); function doOilPaintEffect() { oilPaintEffect(canvas, settings.radius, settings.intensity); } function oilPaintEffect(canvas, radius, intensity) { var width = canvas.width, height = canvas.height, imgData = ctx.getImageData(0, 0, width, height), pixData = imgData.data, // change to createElement getting added element just for the demo destCanvas = document.getElementById("dest-canvas"), dCtx = destCanvas.getContext("2d"), pixelIntensityCount = []; destCanvas.width = width; destCanvas.height = height; var destImageData = dCtx.createImageData(width, height), destPixData = destImageData.data, intensityLUT = [], rgbLUT = []; for (var y = 0; y < height; y++) { intensityLUT[y] = []; rgbLUT[y] = []; for (var x = 0; x < width; x++) { var idx = (y * width + x) * 4, r = pixData[idx], g = pixData[idx + 1], b = pixData[idx + 2], avg = (r + g + b) / 3; intensityLUT[y][x] = Math.round((avg * intensity) / 255); rgbLUT[y][x] = { r: r, g: g, b: b }; } } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixelIntensityCount = []; // Find intensities of nearest pixels within radius. for (var yy = -radius; yy <= radius; yy++) { for (var xx = -radius; xx <= radius; xx++) { if (y + yy > 0 && y + yy < height && x + xx > 0 && x + xx < width) { var intensityVal = intensityLUT[y + yy][x + xx]; if (!pixelIntensityCount[intensityVal]) { pixelIntensityCount[intensityVal] = { val: 1, r: rgbLUT[y + yy][x + xx].r, g: rgbLUT[y + yy][x + xx].g, b: rgbLUT[y + yy][x + xx].b } } else { pixelIntensityCount[intensityVal].val++; pixelIntensityCount[intensityVal].r += rgbLUT[y + yy][x + xx].r; pixelIntensityCount[intensityVal].g += rgbLUT[y + yy][x + xx].g; pixelIntensityCount[intensityVal].b += rgbLUT[y + yy][x + xx].b; } } } } pixelIntensityCount.sort(function(a, b) { return b.val - a.val; }); var curMax = pixelIntensityCount[0].val, dIdx = (y * width + x) * 4; destPixData[dIdx] = ~~(pixelIntensityCount[0].r / curMax); destPixData[dIdx + 1] = ~~(pixelIntensityCount[0].g / curMax); destPixData[dIdx + 2] = ~~(pixelIntensityCount[0].b / curMax); destPixData[dIdx + 3] = 255; } } // change this to ctx to instead put the data on the original canvas dCtx.putImageData(destImageData, 0, 0); } window["reddahApi"].loadCompleted()

body { text-align: center; background: #ececec; font-family: Tahoma, Geneva, sans-serif } section { display: inline-block } canvas { border: 1px solid #000 }
submitted 6 years ago ago by 1b54d14be50240948fc53b199a461f52
picture

Original

仿PS油画滤镜特效


45

var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), img = new Image(), effectEl = document.getElementById("effect"), settings = { radius: 4, intensity: 25, ApplyFilter: function() { doOilPaintEffect(); } } img.addEventListener('load', function() { // reduced the size by half for pen and performance. canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }); function choosePhoto(){ window["reddahApi"].album().then(data=>{ alert(data) img.src=data.replace("file://","http://localhost:8080/_app_file_"); alert(img.src) alert(3) canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); alert(3) }) } img.crossOrigin = "Anonymous"; img.src = "assets/500/501.jpeg"; //"https://wow.techbrood.com/uploads/161001/normal2.jpg"; //var gui = new dat.GUI(); //gui.add(settings, 'intensity'); //gui.add(settings, 'radius'); //gui.add(settings, 'ApplyFilter'); function doOilPaintEffect() { oilPaintEffect(canvas, settings.radius, settings.intensity); } function oilPaintEffect(canvas, radius, intensity) { var width = canvas.width, height = canvas.height, imgData = ctx.getImageData(0, 0, width, height), pixData = imgData.data, // change to createElement getting added element just for the demo destCanvas = document.getElementById("dest-canvas"), dCtx = destCanvas.getContext("2d"), pixelIntensityCount = []; destCanvas.width = width; destCanvas.height = height; var destImageData = dCtx.createImageData(width, height), destPixData = destImageData.data, intensityLUT = [], rgbLUT = []; for (var y = 0; y < height; y++) { intensityLUT[y] = []; rgbLUT[y] = []; for (var x = 0; x < width; x++) { var idx = (y * width + x) * 4, r = pixData[idx], g = pixData[idx + 1], b = pixData[idx + 2], avg = (r + g + b) / 3; intensityLUT[y][x] = Math.round((avg * intensity) / 255); rgbLUT[y][x] = { r: r, g: g, b: b }; } } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixelIntensityCount = []; // Find intensities of nearest pixels within radius. for (var yy = -radius; yy <= radius; yy++) { for (var xx = -radius; xx <= radius; xx++) { if (y + yy > 0 && y + yy < height && x + xx > 0 && x + xx < width) { var intensityVal = intensityLUT[y + yy][x + xx]; if (!pixelIntensityCount[intensityVal]) { pixelIntensityCount[intensityVal] = { val: 1, r: rgbLUT[y + yy][x + xx].r, g: rgbLUT[y + yy][x + xx].g, b: rgbLUT[y + yy][x + xx].b } } else { pixelIntensityCount[intensityVal].val++; pixelIntensityCount[intensityVal].r += rgbLUT[y + yy][x + xx].r; pixelIntensityCount[intensityVal].g += rgbLUT[y + yy][x + xx].g; pixelIntensityCount[intensityVal].b += rgbLUT[y + yy][x + xx].b; } } } } pixelIntensityCount.sort(function(a, b) { return b.val - a.val; }); var curMax = pixelIntensityCount[0].val, dIdx = (y * width + x) * 4; destPixData[dIdx] = ~~(pixelIntensityCount[0].r / curMax); destPixData[dIdx + 1] = ~~(pixelIntensityCount[0].g / curMax); destPixData[dIdx + 2] = ~~(pixelIntensityCount[0].b / curMax); destPixData[dIdx + 3] = 255; } } // change this to ctx to instead put the data on the original canvas dCtx.putImageData(destImageData, 0, 0); } window["reddahApi"].loadCompleted()

body { text-align: center; background: #ececec; font-family: Tahoma, Geneva, sans-serif } section { display: inline-block } canvas { border: 1px solid #000 }
submitted 6 years ago ago by 1b54d14be50240948fc53b199a461f52
picture

Original

仿PS油画滤镜特效


48

var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), img = new Image(), effectEl = document.getElementById("effect"), settings = { radius: 4, intensity: 25, ApplyFilter: function() { doOilPaintEffect(); } } img.addEventListener('load', function() { // reduced the size by half for pen and performance. canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }); function choosePhoto(){ window["reddahApi"].album().then(data=>{ img.src=data.replace("file://","http://localhost:8080/_app_file_"); canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }) } img.crossOrigin = "Anonymous"; img.src = "assets/500/501.jpeg"; //"https://wow.techbrood.com/uploads/161001/normal2.jpg"; //var gui = new dat.GUI(); //gui.add(settings, 'intensity'); //gui.add(settings, 'radius'); //gui.add(settings, 'ApplyFilter'); function doOilPaintEffect() { oilPaintEffect(canvas, settings.radius, settings.intensity); } function oilPaintEffect(canvas, radius, intensity) { var width = canvas.width, height = canvas.height, imgData = ctx.getImageData(0, 0, width, height), pixData = imgData.data, // change to createElement getting added element just for the demo destCanvas = document.getElementById("dest-canvas"), dCtx = destCanvas.getContext("2d"), pixelIntensityCount = []; destCanvas.width = width; destCanvas.height = height; var destImageData = dCtx.createImageData(width, height), destPixData = destImageData.data, intensityLUT = [], rgbLUT = []; for (var y = 0; y < height; y++) { intensityLUT[y] = []; rgbLUT[y] = []; for (var x = 0; x < width; x++) { var idx = (y * width + x) * 4, r = pixData[idx], g = pixData[idx + 1], b = pixData[idx + 2], avg = (r + g + b) / 3; intensityLUT[y][x] = Math.round((avg * intensity) / 255); rgbLUT[y][x] = { r: r, g: g, b: b }; } } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixelIntensityCount = []; // Find intensities of nearest pixels within radius. for (var yy = -radius; yy <= radius; yy++) { for (var xx = -radius; xx <= radius; xx++) { if (y + yy > 0 && y + yy < height && x + xx > 0 && x + xx < width) { var intensityVal = intensityLUT[y + yy][x + xx]; if (!pixelIntensityCount[intensityVal]) { pixelIntensityCount[intensityVal] = { val: 1, r: rgbLUT[y + yy][x + xx].r, g: rgbLUT[y + yy][x + xx].g, b: rgbLUT[y + yy][x + xx].b } } else { pixelIntensityCount[intensityVal].val++; pixelIntensityCount[intensityVal].r += rgbLUT[y + yy][x + xx].r; pixelIntensityCount[intensityVal].g += rgbLUT[y + yy][x + xx].g; pixelIntensityCount[intensityVal].b += rgbLUT[y + yy][x + xx].b; } } } } pixelIntensityCount.sort(function(a, b) { return b.val - a.val; }); var curMax = pixelIntensityCount[0].val, dIdx = (y * width + x) * 4; destPixData[dIdx] = ~~(pixelIntensityCount[0].r / curMax); destPixData[dIdx + 1] = ~~(pixelIntensityCount[0].g / curMax); destPixData[dIdx + 2] = ~~(pixelIntensityCount[0].b / curMax); destPixData[dIdx + 3] = 255; } } // change this to ctx to instead put the data on the original canvas dCtx.putImageData(destImageData, 0, 0); } window["reddahApi"].loadCompleted()

body { text-align: center; background: #ececec; font-family: Tahoma, Geneva, sans-serif } section { display: inline-block } canvas { border: 1px solid #000 }
submitted 6 years ago ago by 1b54d14be50240948fc53b199a461f52
picture

Original

仿PS油画滤镜特效


50

var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), img = new Image(), effectEl = document.getElementById("effect"), settings = { radius: 4, intensity: 25, ApplyFilter: function() { doOilPaintEffect(); } } img.addEventListener('load', function() { // reduced the size by half for pen and performance. canvas.width = (this.width / 2); canvas.height = (this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }); function choosePhoto(){ window["reddahApi"].album().then(data=>{ img.src=data.replace("file://","http://localhost:8080/_app_file_"); canvas.width = "90%"//(this.width / 2); canvas.height = "90%"//(this.height / 2); ctx.drawImage(this, 0, 0, canvas.width, canvas.height); doOilPaintEffect(); }) } img.crossOrigin = "Anonymous"; img.src = "assets/500/501.jpeg"; //"https://wow.techbrood.com/uploads/161001/normal2.jpg"; //var gui = new dat.GUI(); //gui.add(settings, 'intensity'); //gui.add(settings, 'radius'); //gui.add(settings, 'ApplyFilter'); function doOilPaintEffect() { oilPaintEffect(canvas, settings.radius, settings.intensity); } function oilPaintEffect(canvas, radius, intensity) { var width = canvas.width, height = canvas.height, imgData = ctx.getImageData(0, 0, width, height), pixData = imgData.data, // change to createElement getting added element just for the demo destCanvas = document.getElementById("dest-canvas"), dCtx = destCanvas.getContext("2d"), pixelIntensityCount = []; destCanvas.width = width; destCanvas.height = height; var destImageData = dCtx.createImageData(width, height), destPixData = destImageData.data, intensityLUT = [], rgbLUT = []; for (var y = 0; y < height; y++) { intensityLUT[y] = []; rgbLUT[y] = []; for (var x = 0; x < width; x++) { var idx = (y * width + x) * 4, r = pixData[idx], g = pixData[idx + 1], b = pixData[idx + 2], avg = (r + g + b) / 3; intensityLUT[y][x] = Math.round((avg * intensity) / 255); rgbLUT[y][x] = { r: r, g: g, b: b }; } } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixelIntensityCount = []; // Find intensities of nearest pixels within radius. for (var yy = -radius; yy <= radius; yy++) { for (var xx = -radius; xx <= radius; xx++) { if (y + yy > 0 && y + yy < height && x + xx > 0 && x + xx < width) { var intensityVal = intensityLUT[y + yy][x + xx]; if (!pixelIntensityCount[intensityVal]) { pixelIntensityCount[intensityVal] = { val: 1, r: rgbLUT[y + yy][x + xx].r, g: rgbLUT[y + yy][x + xx].g, b: rgbLUT[y + yy][x + xx].b } } else { pixelIntensityCount[intensityVal].val++; pixelIntensityCount[intensityVal].r += rgbLUT[y + yy][x + xx].r; pixelIntensityCount[intensityVal].g += rgbLUT[y + yy][x + xx].g; pixelIntensityCount[intensityVal].b += rgbLUT[y + yy][x + xx].b; } } } } pixelIntensityCount.sort(function(a, b) { return b.val - a.val; }); var curMax = pixelIntensityCount[0].val, dIdx = (y * width + x) * 4; destPixData[dIdx] = ~~(pixelIntensityCount[0].r / curMax); destPixData[dIdx + 1] = ~~(pixelIntensityCount[0].g / curMax); destPixData[dIdx + 2] = ~~(pixelIntensityCount[0].b / curMax); destPixData[dIdx + 3] = 255; } } // change this to ctx to instead put the data on the original canvas dCtx.putImageData(destImageData, 0, 0); } window["reddahApi"].loadCompleted()

body { text-align: center; background: #ececec; font-family: Tahoma, Geneva, sans-serif } section { display: inline-block } canvas { border: 1px solid #000 }
submitted 6 years ago ago by 1b54d14be50240948fc53b199a461f52
picture

Original

仿PS油画滤镜特效


View more: < Prev Next > or try a Random SubReddah