BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"drawImageAlpha V1.1 (Added clipping, lut)"
, by ashcroftman
Mimics the original draw image command, except it now has alpha blending. Looks just about right..
V1.1 Should be alot faster now on a good cpu.
Code
Dim aLut(600,3) ;3X higher than color that could be request...pre-done clamping :) Function initAlphaLut() local r ;--- Dim aLut(600,3) For r=1 To 600 c=r If c>255 c=255 aLut(r,1) = (c And 255) Shl 16 aLut(r,2) = (c And 255) Shl 8 aLut(r,3) = (c And 255) Next ;--- End Function Function drawImageAlpha2(image,x,y,a#) ;V2.0 Faster/Safer. Local drgb,srgb,dX,dY,w,h,na#,nX,nY ;-- LockBuffer LockBuffer ImageBuffer(image) If x<1 x=1 If y<1 y=1 w=ImageWidth(image) h=ImageHeight(image) If x+w>GraphicsWidth() w=w-(x+w-GraphicsWidth()) If y+h>GraphicsHeight() h=h-(y+h-GraphicsHeight()) If a>1 a=1 If a<0 a=0 nA# = 1 - a; For dY= 1 To h For dX = 1 To w nX=dX+x nY=dY+y drgb = ReadPixelFast(dX,dY,ImageBuffer(image)) srgb = ReadPixelFast(nX,nY) WritePixelFast nX,nY,$ff000000 Or aLut( ((srgb Shr 16) And 255) * nA + (((dRgb Shr 16) And 255) * a),1)Or aLut( ((sRgb Shr 8) And 255) * nA + (((dRgb Shr 8) And 255) * a),2 ) Or aLut( (sRgb And 255) * nA + ((dRgb And 255) * a) ,3) Next Next UnlockBuffer ImageBuffer(image) UnlockBuffer ;-- End Function
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations