[Thanks]:24to32, 32to24
Posted: Sat Feb 11, 2012 10:44 am
I am advancing the optimization of the source code not depend in Win32API.
In the image data processing and the audio processing, it has the problem.
Very slow...
As for PureBasic, this processing cannot be done.
The processing of fastest is requested.
Could you create this tips?
Thank you.
In the image data processing and the audio processing, it has the problem.
Very slow...
As for PureBasic, this processing cannot be done.
The processing of fastest is requested.
Could you create this tips?
Code: Select all
Procedure Image32to24(Memory.l,ImageNumber.l)
; Very slow and Depend Win32API
Protected TemporaryDC.l, TemporaryBitmap.BITMAP, TemporaryBitmapInfo.BITMAPINFO
TemporaryDC = CreateDC_("DISPLAY", #Null, #Null, #Null)
GetObject_(ImageID(ImageNumber), 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(ImageNumber), 0, TemporaryBitmap\bmHeight, Memory, TemporaryBitmapInfo, #DIB_RGB_COLORS)
DeleteDC_(TemporaryDC)
;/ Very Difficult HELP ME !!!!
; Protected ImageW.l = ImageWidth(ImageNumber)
; Protected ImageH.l = ImageHeight(ImageNumber)
; Protected ImageSize.l = ImageW*3*ImageH
; Protected Color_from.l, Address.l=0
; For SP_Y=0 To ImageH -1
; For SP_X=0 To ImageW -1
; Color_from = PeekL(Memory+((SP_X+SP_Y*ImageW)*4))
; Color_from = Red(Color_from) <<16 + Green(Color_from) << 8 +Blue(Color_from)
; PokeBits(Memory+Address,0,24, Color_from)
; Address + 3
; Next
; Next
EndProcedure
Procedure Image24to32(Memory.l, ImageNumber.l, Rotate.b=0)
; Slow and but not depend Win32API
Protected SP_X.l, SP_Y.l, Temp.l, Color_from.l
StartDrawing(ImageOutput(ImageNumber))
For SP_Y=0 To OutputHeight()-1
For SP_X=0 To OutputWidth()-1
If Rotate ; rotate 90
Temp = ((OutputHeight()- SP_Y - 1) + (SP_X * OutputHeight())) << 2
Else
Temp = (SP_Y*OutputWidth()+ SP_X) << 2
EndIf
Color_from = Point(SP_X, SP_Y)
Color_from = Red(Color_from)<<16 + Green(Color_from)<<8 + Blue(Color_from)
PokeL(Memory+Temp, Color_from)
Next
Next
StopDrawing()
EndProcedure
Procedure Poke24(Memory.l, 24data.l, BlockSize.l)
; need Audio application
; 32bit Wave Integer to 24 bit Wave Integer for format only
EndProcedure
Procedure Peek24(Memory.l, 32data.l,BlockSize.l)
; need Audio Application for future
; 24 bit Wave Integer to 32 bit Wave Integer for format only
EndProcedure
Global *Image24, *Image32
CreateImage(0, 6400, 4800, 24)
CreateImage(1, 6400, 4800. 32)
StartDrawing(ImageOutput(0))
*Image24 = DrawingBuffer()
StopDrawing()
StartDrawing(ImageOutput(1)
*Image32 = DrawingBuffer()
StopDrawing()
;/ I hope this call like.
Image24to32(0, *Image24, 1, *Image32)
Image32to24(1, *Image32, 0, *Image24)
Poke24(*AudioBuffer, *buffer, 2) ; Stereo
Peek24(*AudioBuffer, *buffer, 2) ; Stereo
End