本文介绍了寻找jQuery插件以从图像中选择颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是jQuery插件,让我从页面上的图像中选择颜色吗?如果到目前为止找到jPipette,那将很复杂.服务器端没有PHP.

Does anyone know are jQuery plugin that let's me pick a color from an image on a page?If found jPipette so far but that is way to complex. Dont have PHP on the server side.

推荐答案

我真的不知道任何插件,我想您将不得不使用canvas之类的东西,

Don't really know of any plugins, I would think you would have to use canvas, something like:

//draw a canvas with an image first, then...

var image = context.getImageData(x, y, width, height),
    pix = image.data,
    color = pix[1000];  // you would need to find the correct pixel, can be done with mouseover or basicly anything you like ?

pix变量中返回的像素数组的格式,每个像素由4个字节的数据表示:

The format of the pixel array returned in the pix variable has each pixel represented by 4 bytes of data:

第一个字节是红色通道

第二个字节是绿色通道

第三个字节是蓝色通道

第4个字节是Alpha频道

4th byte is Alpha channel

每种颜色都是0到255之间的整数.从左到右,从上到下并从索引0开始处理像素.

Each color is an integer between 0 and 255. Pixels are processed from left to right, top to bottom and start at index 0.

这只是为了展示基础知识,与仅输入1000以获得正确的颜色相比,颜色值本身将需要更多的计算,但这是完成的!我假设那里有一个jQuery插件,它使此操作变得容易得多.

This is just to show the basics, and the color value itself will need some more calculations than just typing 1000 to get the correct color, but this is how it's done! I would assume there is a jQuery plugin out there that does this a lot easier.

这里有一个快速教程: http://falcon80.com/HTMLCanvas/PixelManipulation/getImageData. html

There's a quick tutorial here : http://falcon80.com/HTMLCanvas/PixelManipulation/getImageData.html

这篇关于寻找jQuery插件以从图像中选择颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 12:03
查看更多