| .lua Expert Cheater
 
  Reputation: 1 
 Joined: 13 Sep 2018
 Posts: 203
 
 
 | 
			
				|  Posted: Mon Oct 27, 2025 4:30 am    Post subject: Image and bitmap transparency issues |   |  
				| 
 |  
				| 1.As shown in the figure, due to some unknown reason, the image is not a transparent background. 2.Download the CT example below and remove the suffix .lua
 2.I hope you can help me solve the transparency issue
 
 
 
 
	
		
	 
		| Description: |  |  
		| Filesize: | 4.1 KB |  
		| Viewed: | 171 Time(s) |  
		| 
  
 
 |  
 
 
	
		
	 
		| Description: |  |  Download
 |  
		| Filename: | SaveImage.CT.lua |  
		| Filesize: | 151.5 KB |  
		| Downloaded: | 20 Time(s) |  
 |  | 
	
		| AylinCE Grandmaster Cheater Supreme
 
  Reputation: 37 
 Joined: 16 Feb 2017
 Posts: 1527
 
 
 | 
			
				|  Posted: Tue Oct 28, 2025 7:02 am    Post subject: |   |  
				| 
 |  
				| I haven't tried the code with an icon. 
 I assume you can also use the icon in a "png" format.
 
 Here's a clean code that works:
 
 
  	  | Code: |  	  | function drawTextOnImage(imageSource, imageControl, text, x, y, fontColor, showText) -- Load image source
 local pic = type(imageSource) == "userdata" and imageSource or createPicture()
 if type(imageSource) ~= "userdata" then
 pic.loadFromStream(findTableFile(imageSource).stream)
 end
 
 local originalBmp = pic.getBitmap()
 local w, h = originalBmp.Width, originalBmp.Height
 
 -- Create new bitmap
 local srcbmp = createBitmap(w, h)
 srcbmp.TransparentColor = 0x000000
 srcbmp.Transparent = true
 
 -- Copy original image into new bitmap
 srcbmp.Canvas.copyRect(0, 0, w, h, originalBmp.Canvas, 0, 0, w, h)
 
 -- Optionally draw text
 if showText then
 srcbmp.Canvas.Brush.Style = 1 -- bsSolid
 srcbmp.Canvas.Font.Color = fontColor or 0x0000FF
 srcbmp.Canvas.Font.Size = 12
 srcbmp.Canvas.Font.Style = fsBold
 srcbmp.Canvas.Font.Quality = 'fqCleartype'
 srcbmp.Canvas.TextOut(x or 10, y or 10, text or "✔")
 
 -- Debug pixel color (optional)
 -- local px = srcbmp.Canvas.getPixel(x or 10, y or 10)
 -- print(string.format("Pixel color at (%d,%d): 0x%X", x or 10, y or 10, px))
 end
 
 -- Apply bitmap to image control
 imageControl.Picture = srcbmp
 imageControl.TransparentColor = 0x000000
 imageControl.Transparent = true
 
 -- Cleanup
 pic.Destroy()
 srcbmp.Destroy()
 end
 
 -- Create form
 if mf2 then mf2.Destroy() mf2=nil end
 mf2 = createForm()
 mf2.Caption = "test"
 
 -- Create image control
 saveImg = createImage(mf2)
 saveImg.SetPosition(100, 50)
 saveImg.Stretch = true
 
 -- Create button
 btn1 = createButton(mf2)
 btn1.SetPosition(90, 150)
 btn1.Width = saveImg.Width + 20
 btn1.Caption = "Replace Tick: ✔"
 
 -- Text rendering functions
 imageText = function(s) drawTextOnImage("tt.png", saveImg, s, 12, 12, 0x0000FF, true) end
 imageTextClear = function() drawTextOnImage("tt.png", saveImg, nil, nil, nil, false) end
 
 -- Tick symbol table
 tckTbl = { "✔", "✖", "" }
 
 -- Initial tick
 imageText("✔")
 local tck = 1
 
 -- Button click logic
 btn1.OnClick = function()
 tck = tonumber(tck) + 1
 if tckTbl[tck] ~= "" then
 imageText(tckTbl[tck])
 else
 imageTextClear()
 tck = 0
 end
 
 local s = (tck == 0) and tckTbl[#tckTbl] or tckTbl[tck]
 btn1.Caption = "Replace Tick: " .. s
 end
 
 | 
 
 
 
 
	
		
	 
		| Description: |  |  
		| Filesize: | 38.51 KB |  
		| Viewed: | 119 Time(s) |  
		| 
  
 
 |  
 _________________
 
 |  |