Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
cropping an image
Tariq Habtoor
Greenhorn
Posts: 1
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
im really struggling to get this piece of code working and im sure im only missing something very simple, can anyone please help me?
function crop(image, width, height){ //creates new image with dimensions to be cropped var output = new SimpleImage(width, height) for (var pixel of output.values()){ //gets the x and y coordinates of the pixels var x = pixel.getX(); var y = pixel.getY(); // creates a variable called outputPixel that gets its pixel info from the corresponding pixel in the image to be cropped var outputPixel = image.getPixel(x, y); // set the pixel in output image the same at outputPixel output.setPixel(x, y, outputPixel); return output; } } //image to be cropped var start = new SimpleImage("astrachan.jpg"); print(start); var newStart = crop(start, 100, 100); print(newStart);
im not sure whats missing. how can i make it assign RGB values?
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
JavaScript has no native SimpleImage class that I am aware of. Where does this class come from?
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Jasper Report - Text Exporter
Can we resize the image in j2me
How to paste and move an image in java JImagePanel?
Converting a two dimensional int array into a byte array
Drawing Canvas
More...