Posted: Fri Jun 15, 2007 2:23 am
All i can type is thank you. i went to a rock wall climbing gym for the first time today, and i can't move my fingers.
thank you!!!!
thank you!!!!
http://www.purebasic.com
https://www.purebasic.fr/english/
hehehlocalmotion34 wrote:i went to a rock wall climbing gym for the first time today, and i can't move my fingers.
Code: Select all
; Fast Image Routines
;- Procedures
Procedure CopyImageToMemory(ImageNo, Memory)
Protected TemporaryDC.l, TemporaryBitmap.BITMAP, TemporaryBitmapInfo.BITMAPINFO
TemporaryDC = CreateDC_("DISPLAY", #Null, #Null, #Null)
GetObject_(ImageID(ImageNo), SizeOf(BITMAP), TemporaryBitmap.BITMAP)
TemporaryBitmapInfo\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
TemporaryBitmapInfo\bmiHeader\biWidth = TemporaryBitmap\bmWidth
TemporaryBitmapInfo\bmiHeader\biHeight = -TemporaryBitmap\bmHeight
TemporaryBitmapInfo\bmiHeader\biPlanes = 1
TemporaryBitmapInfo\bmiHeader\biBitCount = 32
TemporaryBitmapInfo\bmiHeader\biCompression = #BI_RGB
GetDIBits_(TemporaryDC, ImageID(ImageNo), 0, TemporaryBitmap\bmHeight, Memory, TemporaryBitmapInfo, #DIB_RGB_COLORS)
DeleteDC_(TemporaryDC)
EndProcedure
Procedure CopyMemoryToImage(Memory, ImageNo)
Protected TemporaryDC.l, TemporaryBitmap.BITMAP, TemporaryBitmapInfo.BITMAPINFO
TemporaryDC = CreateDC_("DISPLAY", #Null, #Null, #Null)
GetObject_(ImageID(ImageNo), SizeOf(BITMAP), TemporaryBitmap.BITMAP)
TemporaryBitmapInfo\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
TemporaryBitmapInfo\bmiHeader\biWidth = TemporaryBitmap\bmWidth
TemporaryBitmapInfo\bmiHeader\biHeight = -TemporaryBitmap\bmHeight
TemporaryBitmapInfo\bmiHeader\biPlanes = 1
TemporaryBitmapInfo\bmiHeader\biBitCount = 32
TemporaryBitmapInfo\bmiHeader\biCompression = #BI_RGB
SetDIBits_(TemporaryDC, ImageID(ImageNo), 0, TemporaryBitmap\bmHeight, Memory, TemporaryBitmapInfo, #DIB_RGB_COLORS)
DeleteDC_(TemporaryDC)
EndProcedure
Procedure SwapRGB(Color)
ProcedureReturn ((Color & $FF) << 16) | (Color & $FF00) | ((Color & $FF0000) >> 16)
EndProcedure
;- Macros
Macro RGB(Red, Green, Blue)
(((Blue << 8 + Green) << 8 ) + Red )
EndMacro
Macro FastRed(Color)
Color & 255
EndMacro
Macro FastGreen(Color)
(Color & 65535) >> 8
EndMacro
Macro FastBlue(Color)
(Color & 16777215) >> 16
EndMacro
Macro FastPlot(x, y, Color)
PokeL(*Memory + (x + ImageWidth * (y)) << 2, SwapRGB(Color))
EndMacro
Macro FastPoint(x, y)
SwapRGB(PeekL(*Memory + (x + ImageWidth * (y)) << 2))
EndMacroCode: Select all
ProcedureDLL imgm_InvertColors(image)
;Invert the colors
hBmp=ImageID(image)
If hBmp
imageWidth=ImageWidth(image)
imageHeight=ImageHeight(image)
mem=AllocateMemory(imageWidth*imageHeight*4)
bmi.myBITMAPINFO
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = imageWidth
bmi\bmiHeader\biHeight = imageHeight
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
hdc = StartDrawing(ImageOutput(image))
Debug hdc
GetDIBits_(hdc,hBmp,0,imageHeight,mem,bmi,#DIB_RGB_COLORS)
*pixels.LONG = mem
For A = 1 To imageWidth*(imageHeight)
*pixels\l - *pixels\l - *pixels\l
*pixels + 4
Next A
SetDIBits_(hdc,hBmp,0,imageHeight,mem,bmi,#DIB_RGB_COLORS) ;<> 0
StopDrawing()
ProcedureReturn 1
EndIf
EndProcedure