mikromundo Posted December 20, 2019 Share Posted December 20, 2019 Hi, Someone can help me !!! How can I get a PIXEL COLOR on uniIMAGE or uniPANEL ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 20, 2019 Share Posted December 20, 2019 8 minutes ago, mikromundo said: How can I get a PIXEL COLOR on uniIMAGE or uniPANEL ? Hi, Can you please explain in more detail? Quote Link to comment Share on other sites More sharing options...
mikromundo Posted December 20, 2019 Author Share Posted December 20, 2019 Hi Sherzod, I want to put the mouse ON THE IMAGE and click...and GET the COLOR of the PIXEL clicked. Quote Link to comment Share on other sites More sharing options...
mikromundo Posted December 20, 2019 Author Share Posted December 20, 2019 I found this, but I can´t resolve the color. I put this onMouseUp: var myColor:TColor; Pxl:TBitmap; begin Pxl:=TBitmap.Create; Pxl.Width:=1; Pxl.Height:=1; BitBlt(Pxl.Canvas.Handle,0,0,1,1,GetDC(0), x , y,SRCCOPY); myColor:=Pxl.Canvas.Pixels[0,0]; end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 20, 2019 Share Posted December 20, 2019 It will not work this way. I will analyze. Quote Link to comment Share on other sites More sharing options...
mikromundo Posted December 20, 2019 Author Share Posted December 20, 2019 Yes...I know...rrrsr Thanks so much !!! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 20, 2019 Share Posted December 20, 2019 2 hours ago, mikromundo said: How can I get a PIXEL COLOR on uniIMAGE One possible solution... 1. UniImage1.ClientEvents... function mousedown(sender, x, y, eOpts) { var me=sender; if (!me._img) { var src = me.getEl().down('img').dom.src; var imgMain = me.getEl().down('img'); me._img = new Image(); me._canvas = document.createElement('canvas'); $(me._img).load(function() { me._canvas.width = imgMain.getWidth(); me._canvas.height = imgMain.getHeight(); me._canvas.getContext('2d').drawImage(me._img, 0, 0, me._canvas.width, me._canvas.height); //console.log(x, y, me._canvas.getContext('2d').getImageData(x, y, 1, 1).data); var rgbData = me._canvas.getContext('2d').getImageData(x, y, 1, 1).data; ajaxRequest(me, 'getColorRGB', ['r='+rgbData[0], 'g='+rgbData[1], 'b='+rgbData[2]]); }); me._img.src = src; } else { //console.log(x, y, me._canvas.getContext('2d').getImageData(x, y, 1, 1).data); var rgbData = me._canvas.getContext('2d').getImageData(x, y, 1, 1).data; ajaxRequest(me, 'getColorRGB', ['r='+rgbData[0], 'g='+rgbData[1], 'b='+rgbData[2]]); } } 2. UniImage1.OnAjaxEvent procedure TMainForm.UniImage1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'getColorRGB' then UniPanel1.Color := RGB(Params.Values['r'].ToInteger(), Params.Values['g'].ToInteger(), Params.Values['b'].ToInteger()); end; 1 Quote Link to comment Share on other sites More sharing options...
mikromundo Posted December 21, 2019 Author Share Posted December 21, 2019 Great!! thank so much... http://jsfiddle.net/thirtydot/9SEMf/869/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.