Code-Beispiel
Alle Pixel aus einem Image Pointer holen
Lizenz: | Erster Autor: | Letzte Bearbeitung: |
GPL | jakidomi | 06.12.2009 |
Beispiel
#Include "getpixel.bi"
#include "jpeg4fb.bas"
screen 18,32
dim as any ptr img
dim as pixel pix()
img= jpegget("miloan.jpg")
dim as uinteger w,h
dim as double ti,tig=timer
imageinfo(img,w,h)
ti=timer
consprint"Generiere Pixel Liste"
getAllPixel(pix(),img)
consprint"Fertig - pixel: "+str(ubound(pix))
consprint str(abs(timer-ti))
ti=timer
consprint"Draw Pixels"
PutAllPixel(0,0,w,h,pix())
consprint"Fertig - pixel: "+str(ubound(pix))
consprint str(abs(timer-ti))
consprint str(abs(timer-tig))
getkey
<hr>
GetPixel.bi
#Include once "fbgfx.bi"
#include once "fonts.bi"
Using FB
type pixel
r as ubyte
g as ubyte
b as ubyte
a as ubyte
f as uinteger
declare sub i()
declare constructor ()
end type
constructor pixel()
this.f=rgba(this.r,this.g,this.b,this.a)
end constructor
sub pixel.i()
this.f=rgba(this.r,this.g,this.b,this.a)
end sub
sub getAllPixel(pix() as pixel,img as any ptr)
dim as uinteger u,t,w,h
imageinfo(img,w,h)
for y as integer=0 to h
for x as integer=0 to w
t=point(x,y,img)
u+=1
redim preserve pix(u)
pix(u).r=getrot(t)' hole rot wert aus farbcode t
pix(u).g=getgruen(t)' hole grün wert aus farbcode t
pix(u).b=getblau(t)' hole blau wert aus farbcode t
pix(u).a=getalpha(t)' hole alpha wert aus farbcode t
pix(u).i
next
next
end sub
sub setAllPixel(pix() as pixel,img as any ptr)
dim as uinteger u,t,w,h
imageinfo(img,w,h)
for y as integer=0 to h
for x as integer=0 to w
if u>ubound(pix) then exit for
pset img,(x,y),pix(u).f
next
next
end sub
sub PutAllPixel(x as integer,y as integer,w as uinteger,h as uinteger,pix() as pixel)
dim as uinteger u
for yy as integer=0 to h
if yy+y>scy then exit for
for xx as integer=0 to w
u+=1
if u>ubound(pix) then exit for
if xx+x>scx then u+=w-xx:exit for' consprint str(xx+x)+" - "+str(scx)+" - "+str(u)'exit for
pset (x+xx,y+yy),pix(u).f
next
next
end sub
Zusätzliche Informationen und Funktionen | |||||||
---|---|---|---|---|---|---|---|
|