February 27, 2021, 02:55:54 AM

Author Topic: [bmx] Setimagemask by dynaman [ 1+ years ago ]  (Read 437 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Setimagemask by dynaman [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Setimagemask
Author : dynaman
Posted : 1+ years ago

Description : Set the mask color of an image after it has been loaded

Code :
Code: BlitzMax
  1. Function setimagemask(p_image:Timage, p_red,p_green,p_blue)
  2.         Local l_maskrgb
  3.         Local l_maskargb
  4.         Local l_pixelrgb
  5.         Local l_pixelraw
  6.         Local l_x,l_y
  7.         Local l_pix1:Tpixmap
  8.        
  9.         l_maskrgb = p_red * 65536 + p_green * 256 + p_blue
  10.         l_pix1 = LockImage(p_image)
  11.         For l_x = 0 To ImageWidth(p_image)
  12.                 For l_y = 0 To ImageHeight(p_image)
  13.                         l_pixelraw = ReadPixel(l_pix1,l_x,l_y)
  14.                         l_pixelrgb = l_pixelraw & 16777215
  15.                         If l_pixelrgb = l_maskrgb Then
  16.                                 WritePixel(l_pix1,l_x,l_y,l_maskrgb)
  17.                         End if
  18.                 Next
  19.         next
  20.  
  21.         UnlockImage(p_image)
  22.         Release l_pix1
  23. End function


Comments :


Baystep Productions(Posted 1+ years ago)

 I'll sum that up to...MaskImage img,r,b,gAnd it does it after it has been loaded!


dynaman(Posted 1+ years ago)

 That is pretty much it.  Sorry if I wasn't clear - docs are not my thing...


(tu) ENAY(Posted 1+ years ago)

 This throws an error in the newest version of Blitzmax because you should be doing:-For l_x = 0 To ImageWidth(p_image)-1For l_y = 0 To ImageHeight(p_image)-1:)


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal