change image to grayscale on fly

For general discussion related FlowStone
Post Reply
Logado
Posts: 62
Joined: Tue Jan 06, 2015 5:42 pm

change image to grayscale on fly

Post by Logado »

This is possible on the fly to change the color of the image. Methods of work with images not found :cry:
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: change image to grayscale on fly

Post by KG_is_back »

In ruby, there are no methods to read or change pixels of a bitmap. In green, there are getPixel and setPixel prims, but to alter entire image you'd need enormous loops, which would likely create massive CPU waste.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: change image to grayscale on fly

Post by tulamide »

You could make use of the FreeImage Project. You would then download the FreeImage DLL (http://freeimage.sourceforge.net/download.html) and access the functions you need using Ruby's Win32API dll access as explained in the User Guide. It takes some time to set them up, but then you are able to do those on-the-fly conversions.
"There lies the dog buried" (German saying translated literally)
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: change image to grayscale on fly

Post by Nubeat7 »

there is also the color matrix, you can use this for changing colors of images.
Youlean
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: change image to grayscale on fly

Post by Youlean »

Try this... (It is not mine pack)
Attachments
gui pack.fsm
(31.31 KiB) Downloaded 842 times
Logado
Posts: 62
Joined: Tue Jan 06, 2015 5:42 pm

Re: change image to grayscale on fly

Post by Logado »

Thanks for answers.
I need it to show that the element is not active. Make a simple method.

v.drawBitmapSection @Spriteimg,[0,image_y,48,16],[0,0,6,2]
if @disable == 1
c1 = Color.new 180,53,60,70 #background color
c1 = Color.new 180,53,40,70
r = [0,0,v.width,v.height]
b = LinearGradientBrush.new r,c1,c2,0,true
v.drawRectangle b,r
end
Post Reply