Drag and drop image 1bitifier

Developer
Size
2,087 Kb
Views
8,096

How do I make an drag and drop image 1bitifier?

What is a drag and drop image 1bitifier? How do you make a drag and drop image 1bitifier? This script and codes were developed by Elliot on 22 December 2022, Thursday.

Drag and drop image 1bitifier Previews

Drag and drop image 1bitifier - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>drag and drop image 1bitifier</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="dropzone"> <b>1.</b> Drag Image File Here </br>
<canvas id="c"></canvas>
</div> <script src="js/index.js"></script>
</body>
</html>

Drag and drop image 1bitifier - Script Codes CSS Codes

#dropzone { min-height: 200px; min-width: 100%; background: black; color: white; font-size: 40px; font-family: arial;
}

Drag and drop image 1bitifier - Script Codes JS Codes

const dropZone = document.getElementById('dropzone')
const c = document.getElementById('c')
const ctx = c.getContext('2d')
function ditherImage(img) { c.height = img.height c.width = img.width ctx.drawImage(img, 0, 0) //for(let x=0; x < c.width; x++) //for(let y=0; y < c.height; y++) const imageData = ctx.getImageData(0, 0, c.width, c.height) const d = imageData.data dither(d) ctx.putImageData(imageData, 0, 0)
}
function dither(d) { let err = 0 for (let i = 0; i < d.length; i += 4) { const avg = (d[i] + d[i + 1] + d[i + 2]) / 3 | 0 let result = 0 if (avg + err > 127){ result = 255 //white err = avg + err - 255 } else { result = 0 //black err = avg + err } d[i] = result // red d[i + 1] = result // green d[i + 2] = result // blue }
}
dropzone.addEventListener('dragover', e=>e.preventDefault(), false)
dropzone.addEventListener('dragenter', e=>e.preventDefault(), false)
dropzone.addEventListener('drop', e =>{	e.preventDefault()	const fs = e.dataTransfer.files createImageBitmap(fs[0]).then(ditherImage)	})
Drag and drop image 1bitifier - Script Codes
Drag and drop image 1bitifier - Script Codes
Home Page Home
Developer Elliot
Username vez
Uploaded December 22, 2022
Rating 3
Size 2,087 Kb
Views 8,096
Do you need developer help for Drag and drop image 1bitifier?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Elliot (vez) Script Codes
Create amazing sales emails with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!