DrawImageArea
Übersicht

DreamoraBetreff: DrawImageArea |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Entspricht dem Verhalten von DrawImageRect im alten BlitzBasic.
Kopiert einfach den Source in eine Datei, die ihr dann importiert. l = x Koordinate des oberen Punktes wo man mit zeichnen beginnen will t = y Koordinate des oberen Punktes wo man mit zeichnen beginnen will w,h = Breite und Höhe des Bildausschnittes den man zeichnen will. Code: [AUSKLAPPEN] Strict ?Win32 Import brl.d3d7max2d ? Import brl.glmax2d Function drawimagearea (image:TImage, x#, y#, l#, t#, w#, h#, frame=0) Assert l < image.width Else "l muss kleiner als die Bildbreite sein" Assert t < image.height Else "t muss kleiner als die Bildhöhe sein" Local origin_x#,origin_y# GetOrigin (origin_x,origin_y) Local l1# = l + w Local h1# = t + h Local x0#=-image.handle_x,x1#=x0+w Local y0#=-image.handle_y,y1#=y0+h If l1 > image.width x1 = x0 + w + image.width - l1 l1 = image.width EndIf If h1 > image.height y1 = y0 + h + image.height - h1 h1 = image.height EndIf If TGLIMAGEFRAME (image.frame(frame)) Local imgFrame:TGLImageFrame = TGLImageFrame (image.Frame(Frame)) imgFrame.u0 = l / image.Width imgFrame.v0 = t / image.Height imgFrame.u1 = (l1) / image.Width imgFrame.v1 = (h1) / image.Height image.Frame(Frame).Draw x0,y0,x1,y1,X+origin_x,Y+origin_y imgFrame.u0 = 0 imgFrame.v0 = 0 imgFrame.u1 = 1 imgFrame.v1 = 1 Else Local imgFrame:TD3D7ImageFrame = TD3D7ImageFrame (image.Frame(Frame)) imgFrame.SetUV (l/image.Width, t/image.Height, (l1) / image.Width, (h1) / image.Height) image.Frame(frame).Draw x0,y0,x1,y1,x+origin_x,y+origin_y imgFrame.SetUV (0,0,1,1) EndIf End Function EDITIERT für 1.28 EDIT: Nach unterem Post und der Klärung: Der Code ist nicht als Standalone tauglich, sondern um ihn in eine BMX zu packen und zu importieren in eine richtige Anwendung. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
- Zuletzt bearbeitet von Dreamora am So, Feb 10, 2008 19:56, insgesamt 2-mal bearbeitet
![]() |
Freeman |
![]() Antworten mit Zitat ![]() |
---|---|---|
habe deinen source grad kompiliert und bekomme folgende meldung :
Code: [AUSKLAPPEN] Building untitled2 Compiling:untitled2.bmx Compile Error: Unable to convert from 'TGLIMAGEFRAME' to 'Int' [C:/Programme/BlitzMax/tmp/untitled2.bmx;35;7] Process complete FrEeMaN |
||
MacBook | MacOSX 10.5 | 80GB HDD | 1GB | BlitzMax 1.28 |
![]() |
Suco-XBetreff: ..... |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi
Nur aus interesse, was gibt es an der alten Version, die mit Viewport, ausszusetzen? Code: [AUSKLAPPEN] Function DrawImageArea(Image:TImage, x:Float, y:Float,.. l:Float, t:Float, w:Float, h:Float, Frame:Int=0) Local tx:Int, ty:Int Local tw:Int, th:Int GetViewport(tx, ty, tw, th) SetViewport(l, h, w, h) DrawImage Image, x, y, Frame SetViewport(tx, ty, tw, th) End Function Mfg Suco |
||
Intel Core 2 Quad Q8300, 4× 2500 MHz, 4096 MB DDR2-Ram, GeForce 9600GT 512 MB |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Es ist einfacher und wahrscheinlich auch schneller, da DX kein ScissorTest hat wie OpenGL. Von Kompatibilitätsproblemen mit älteren Karten abgesehen.
Natürlich kann auch jeder deine Variante nutzen. Habs nur geschrieben weil ich mehrfach über das Problem des inexistenten DrawImageRect a la "old blitz" gestolpert bin im D und E Forum. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Gefixt damit es auch mit der aktuellen BM Version wieder geht | ||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group