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!!!!
Any Other Image formats/Routines for supporting?
-
localmotion34
- Enthusiast

- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
- Dreamland Fantasy
- Enthusiast

- Posts: 335
- Joined: Fri Jun 11, 2004 9:35 pm
- Location: Glasgow, UK
- Contact:
@thefool
FastImage routines:
Kind regards,
Francis
FastImage routines:
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))
EndMacroFrancis
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re:
This standalone snippet doesn't seem to work anymore; I get square blocks of color in the converted image, in some places. Does it need something new since the latest PureBasic? (I know I can use the other Invert code in this thread, but I prefer to use this shorter code, and besides, I'm interested to know why it suddenly doesn't work anymore).
Code: 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
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Any Other Image formats/Routines for supporting?
You don't need those old hacks anymore!
First of all because Point()/Plot() got a lot faster in PB 4.40(?), and second because you can use DrawingBuffer() for direct access to the image pixels.
To answer your question: I think it doesn't work anymore because of this: http://www.purebasic.fr/blog/?p=196
First of all because Point()/Plot() got a lot faster in PB 4.40(?), and second because you can use DrawingBuffer() for direct access to the image pixels.
To answer your question: I think it doesn't work anymore because of this: http://www.purebasic.fr/blog/?p=196
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
