Auflösung verdoppeln

Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Neue Antwort erstellen

 

battlegorge

Betreff: Auflösung verdoppeln

BeitragMo, Sep 10, 2007 18:30
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich möchte das Programm in 320*240 laufen lassen und vor dem flip
das Bild auf 640*480 skalieren.
Ich habe es schon mit pixmaps versucht aber mit der Methode braucht ein frame 130 ms Embarassed
Ausserdem wird das Bild nicht wie bei Paint normal verdoppelt, sondern seltsam gefiltert.
Wie würdet ihr das machen?
Code: [AUSKLAPPEN]
Strict

Graphics 640,480,0,75

Global image:timage=LoadImage("image.bmp")

Global ms1,ms2

Repeat
   ms1=MilliSecs()
   DrawImage image,0,0
   f_draw()
   ms2=MilliSecs()-ms1
   DrawText ms2,10,10
   Flip
   Cls
Until KeyHit(key_escape) Or AppTerminate()

Function f_draw()
   Local pix1:TPixmap=GrabPixmap(0,0,320,240)
   Local pix2:TPixmap=ResizePixmap(pix1,640,480)
   DrawPixmap pix2,0,0
End Function

mahe

BeitragMo, Sep 10, 2007 18:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]

global im:TImage = CreateImage(320,240,1,0)
Function f_draw()
  GrabImage im,0,0
  SetScale 2,2
  DrawImage im,0,0
  SetScale 1,1
EndFunction

sollte um einiges schneller sein.

Bei CreateImage bei den Flags 0 angeben dann wird auch nicht "gesmoothed".
ʇɹǝıdɯnɹɹoʞ ɹnʇɐuƃıs - ǝpoɥʇǝɯ-ɹoɹɹıɯ ɹǝp uı ,ɹoɹɹǝ,
 

battlegorge

BeitragMo, Sep 10, 2007 22:07
Antworten mit Zitat
Benutzer-Profile anzeigen
Das ist schon deutlich schneller.
Aber die Berechnung dauert immernoch 20 ms.
Gibts noch eine andere Methode?

mahe

BeitragMo, Sep 10, 2007 22:20
Antworten mit Zitat
Benutzer-Profile anzeigen
Außer alle Bilder vorher schon skaliert zu zeichnen fällt mir sonst nichts ein.
Du müsstest dazu nur den SetScale-Befehl an den Anfang setzen und alle Positionsangaben verdoppeln.
ʇɹǝıdɯnɹɹoʞ ɹnʇɐuƃıs - ǝpoɥʇǝɯ-ɹoɹɹıɯ ɹǝp uı ,ɹoɹɹǝ,

FOODy

BeitragMo, Sep 10, 2007 22:44
Antworten mit Zitat
Benutzer-Profile anzeigen
Mal den Thread mal ansehen: http://www.blitzbasic.com/Comm...opic=66775

Da ist auch dieser Code bei:
Code: [AUSKLAPPEN]
Strict

Type TVirtualGraphics
   Global virtualWidth, virtualHeight
   Global xRatio!, yRatio!
   
   Function Set(width=640, height=480)
      TVirtualGraphics.virtualWidth = width
      TVirtualGraphics.virtualHeight = height
      TVirtualGraphics.xRatio! = width / Double(GraphicsWidth())
      TVirtualGraphics.yRatio! = height / Double(GraphicsHeight())
      
   ?Win32
      Local D3D7Driver:TD3D7Max2DDriver = TD3D7Max2DDriver(_max2dDriver)
         
      If D3D7Driver
         Local matrix#[] = [2.0 / width, 0.0, 0.0, 0.0,..
                                        0.0, -2.0 / height, 0.0, 0.0,..
                                        0.0, 0.0, 1.0, 0.0,..
                                        -1 - (1.0 / width), 1 + (1.0 / height), 1.0, 1.0]
         
         D3D7Driver.device.SetTransform(D3DTS_PROJECTION, matrix)
      Else
   ?
      glMatrixMode(GL_PROJECTION)
      glLoadIdentity()
      glortho(0, width, height, 0, 0, 1)
      glMatrixMode(GL_MODELVIEW)
      glLoadIdentity()
   ?Win32
      EndIf
   ?
   End Function
   
   Function MouseX()
      Return (BRL.PolledInput.MouseX() * TVirtualGraphics.xRatio!)
   End Function
   
   Function MouseY()
      Return (BRL.PolledInput.MouseY() * TVirtualGraphics.yRatio!)
   End Function
End Type

'----------------------------------------------- TEST -----------------------------------------------

'SetGraphicsDriver GLMax2DDriver()
SeedRnd MilliSecs()

Local index = Rand(0, CountGraphicsModes() - 1)
Local screenW, screenH, screenD, screenR

GetGraphicsMode(index, screenW, screenH, screenD, screenR)

Graphics screenW, screenH, screenD
TVirtualGraphics.Set(1024, 768)

HideMouse
AutoMidHandle True

Local image:TImage = LoadImage(getenv_("BMXPATH") + "/doc/bmax120.png")
Assert image Else "Oi..."

Local x = Rand(0, TVirtualGraphics.virtualWidth - 1)
Local y = Rand(0, TVirtualGraphics.virtualheight - 1)
Local xInc = Rand(1, 4)
Local yInc = Rand(1, 4)
Local scale#

SetClsColor 0, 0, 100

Repeat
   x :+ xInc
   If x >= TVirtualGraphics.virtualWidth
      x = TVirtualGraphics.virtualWidth - 1
      xInc = -xInc
   ElseIf x < 0
      x = 0
      xInc = -xInc
   EndIf
   
   y :+ yInc
   If y >= TVirtualGraphics.virtualHeight
      y = TVirtualGraphics.virtualHeight - 1
      yInc = -yInc
   ElseIf y < 0
      y = 0
      yInc = -yInc
   EndIf
   
   scale# = 1 + (Cos(MilliSecs() / 10.0) * 0.5)
   
   Cls
   SetTransform(Sin(MilliSecs() / 40.0) * 180.0, scale#, scale#)
   DrawImage image, x, y
   
   SetTransform(0, TVirtualGraphics.xRatio!, TVirtualGraphics.xRatio!)
   DrawText screenW + " x " + screenH + " x " + screenD, 12, 12
   
   Plot TVirtualGraphics.MouseX(), TVirtualGraphics.MouseY()

   Flip
Until KeyHit(KEY_ESCAPE)

End


Der könnte dir eventuell weiterhelfen.


Gruß,
FOODy
BlitzMax + MaxGUI, 64-bit Arch Linux: Intel Core² E8500 | 8 GB Ram | GeForce GTX 460 · 1024 MB
 

battlegorge

BeitragDi, Sep 11, 2007 15:47
Antworten mit Zitat
Benutzer-Profile anzeigen
Der code aus dem blitzbasic forum sieht interessant aus.
Aber etwas kompliziert. Shocked

Die Idee alle Bilder direkt zu vergrössern ist gut.
Ich glaube so mache ichs.

Rallimen

Sieger des 30-EUR-Wettbewerbs

BeitragDi, Sep 11, 2007 23:54
Antworten mit Zitat
Benutzer-Profile anzeigen
ich habe einen Code der Bilder ca 100x schneller vergrößert als
Scaleimage 2,2 (mit Tformfilter 0),
vielleicht läßt der sich auf Bmax umstricken !?

Code: [AUSKLAPPEN]
Graphics 800 ,600,16,2
; Bild erstellen
img = CreateImage (320 ,240)
SetBuffer ImageBuffer (img)
Color 0 ,255,255
Oval 0 ,0,320,240
;
Time = MilliSecs ()
img = ScaleImageHoch2 (img)
time = MilliSecs () - time
;
SetBuffer BackBuffer ()
While Not KeyDown (1)
    DrawBlock img,0,0
    Text 0 ,550,time + " Millisekunden "
    Flip
    Cls
Wend
End
Function ScaleImageHoch2 (img) ; Bild schnell vergrößern (Scaleimage img, 2,2)
    ;
    Img1 = CreateImage (ImageWidth (img) * 2 ,ImageHeight (img) * 2)
    ;
    For x = 0 To ImageWidth (img) - 1
        CopyRect x,0,1,ImageHeight (img) ,x * 2 ,0, ImageBuffer (img) ,ImageBuffer (img1)
        CopyRect x,0,1,ImageHeight (img) ,x * 2 + 1 ,0, ImageBuffer (img) ,ImageBuffer (img1)
    Next
    ;
    For y = ImageHeight (img) - 1 To 0 Step - 1
        CopyRect 0 ,y,ImageWidth (img1) ,1,0,y * 2, ImageBuffer (img1) ,ImageBuffer (img1)
        CopyRect 0 ,y,ImageWidth (img1) ,1,0,y * 2 + 1, ImageBuffer (img1) ,ImageBuffer (img1)
    Next
    ;
    FreeImage img
    Return img1
End Function
[BB2D | BB3D | BB+]

mahe

BeitragMi, Sep 12, 2007 0:03
Antworten mit Zitat
Benutzer-Profile anzeigen
Das hätte nicht viel Sinn.

Bei BMax werden alle Bilder als Texturen auf 3D-Objekte (Sprites) geladen und mittels OpenGL (DirectX ist auch möglich) gerendert.
Somit ist die Vergrößerung mit SetScale noch viel schneller als Deine Funktion.
ʇɹǝıdɯnɹɹoʞ ɹnʇɐuƃıs - ǝpoɥʇǝɯ-ɹoɹɹıɯ ɹǝp uı ,ɹoɹɹǝ,

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group