Code: Alles auswählen
Declare CopyImageToMem(Img.l, *mem)
Declare CopyMemToImage(Img.l, *mem)
CountOfIcons=100000
w = 32
h = 32
cb = 3 ; color bytes (3 or 4)
ims = w*h*cb ; image memory size
*buffer = AllocateMemory(CountOfIcons * ims)
For x = 0 To CountOfIcons
i=CreateImage(#PB_Any , w, h, cb*8, RGB(Mod(x,255),Mod(x,223),Mod(x,191)))
CopyImageToMem(i, *buffer + ims*x)
FreeImage(i)
Next
x=0
OpenWindow(0, 96, 96, 160, 96, "Only one ImageID")
Target=CreateImage(#PB_Any, w, h, cb*8, RGB(255,255,255))
ImageGadget(0, 32, 32, w, h, ImageID(Target), #PB_Image_Border)
AddWindowTimer(0, 0, 10)
Repeat
Event = WaitWindowEvent()
If (Event = #PB_Event_Timer)
x+1 : If x = CountOfIcons : x = 0 : EndIf
CopyMemToImage(Target, *buffer + ims*x)
SetGadgetState(0, ImageID(Target))
EndIf
Until Event = #PB_Event_CloseWindow
; http://www.purebasic.fr/german/viewtopic.php?t=1164 :
Procedure CopyImageToMem(Img.l, *mem)
Protected bmi.BITMAPINFO
Protected w.l, h.l, hBmp.l, hDC.l
w = ImageWidth(Img)
h = ImageHeight(Img)
hBmp = ImageID(Img)
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = w
bmi\bmiHeader\biHeight = h
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
hDC = StartDrawing(ImageOutput(Img))
If GetDIBits_(hDC, hBmp, 0, h, *mem, bmi, #DIB_RGB_COLORS)
StopDrawing()
ProcedureReturn #True
Else
StopDrawing()
ProcedureReturn #False
EndIf
EndProcedure
Procedure CopyMemToImage(Img.l, *mem)
Protected bmi.BITMAPINFO
Protected w.l, h.l, hBmp.l, hDC.l
w = ImageWidth(Img)
h = ImageHeight(Img)
hBmp = ImageID(Img)
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = w
bmi\bmiHeader\biHeight = h
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
hDC = StartDrawing(ImageOutput(Img))
If SetDIBits_(hDC, hBmp, 0, h, *mem, bmi, #DIB_RGB_COLORS)
StopDrawing()
ProcedureReturn #True
Else
StopDrawing()
ProcedureReturn #False
EndIf
EndProcedure