Posted: Sun Mar 09, 2008 1:39 am
Removed.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
bmp.BITMAP
For t=0 To 5000
hbmp=CreateImage(t, 16,16, 4)
n=GetObject_(hbmp, SizeOf(BITMAP), bmp)
; Debug bmp\bmBits
If bmp\bmBits&$FFFF
Debug bmp\bmBits&$FFFF ; output if it's not aligned to 65536 bytes
EndIf
If bmp\bmBits=0
Debug "no bits"
EndIf
Next
Debug "end"
End
Code: Select all
Procedure.b GrayScaleImg ( ImgID.l ); Works only with 32 Bit Images!!
Protected Grey.l
#lumared = 3
#lumagreen = 6
#lumablue = 1
If Not IsImage( ImgID ) Or Not GetObject_(ImageID(ImgID), SizeOf(BITMAP), bmp.BITMAP) : ProcedureReturn #False : EndIf
*ptr.RGBQUAD = bmp\bmBits
Size = *ptr + ImageWidth(ImgID) * ImageHeight(ImgID) * 4 - 4
Repeat
Grey = (#lumared * *ptr\rgbRed&$FF + #lumagreen * *ptr\rgbGreen&$FF + #lumablue * *ptr\rgbBlue&$FF) / 10
*ptr\rgbRed = Grey
*ptr\rgbGreen = *ptr\rgbRed
*ptr\rgbBlue = *ptr\rgbRed
*ptr + 4
Until *ptr > Size
ProcedureReturn #True
EndProcedure
If CreateImage( 1, 4000, 4000, 32)
time = ElapsedMilliseconds()
GrayScaleImg( 1 )
MessageRequester("", Str(ElapsedMilliseconds() - time), 0)
EndIf
Fred wrote:Did you run with debugger off ?
Code: Select all
Procedure.b GrayScaleImg ( ImgID.l ); Works only with 32 Bit Images!!
#lumared = 77
#lumagreen = 153
#lumablue = 26
If Not IsImage( ImgID ) Or Not GetObject_(ImageID(ImgID), SizeOf(BITMAP), bmp.BITMAP) : ProcedureReturn #False : EndIf
Structure Pixel
StructureUnion
RGB.RGBQUAD
Mem.Long
EndStructureUnion
EndStructure
*ptr.Pixel = bmp\bmBits
Size = *ptr + ImageWidth(ImgID) * ImageHeight(ImgID) * 4 - 4
Repeat
*ptr\Mem\l=((#lumared * *ptr\RGB\rgbRed&$FF + #lumagreen * *ptr\RGB\rgbGreen&$FF + #lumablue * *ptr\RGB\rgbBlue&$FF) >> 8)*$10101
*ptr + 4
Until *ptr > Size
ProcedureReturn #True
EndProcedure
If CreateImage( 1, 4000, 4000, 32)
time = ElapsedMilliseconds()
GrayScaleImg( 1 )
MessageRequester("", Str(ElapsedMilliseconds() - time), 0)
EndIf
Did some quick tests now, wilbert - on my computer, the following timing can be seen:wilbert wrote:I created a grayscale module [...] how it compares to the other solutions.
Thanks for the infoMichael Vogel wrote:Did some quick tests now, wilbert - on my computer, the following timing can be seen: