Komischer Datenmüll in neuer Pixmap

Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Neue Antwort erstellen

Firstdeathmaker

Betreff: Komischer Datenmüll in neuer Pixmap

BeitragMi, Okt 05, 2005 1:01
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich versuche gerade einen Isotilecreator zu schreiben der auch transparente PNG´s erstellen kann. Leider sind bei den neu erstellten Pixmaps aber oben ein paar Pixel in zufallsfarben vorhanden, ich weis aber nicht woran das liegt.

Code: [AUSKLAPPEN]
'Isotilecreator by Christian Geißler
Strict

Graphics 400,300,0

Global QImage:TPixmap'Quellimage
Global Qheight,Qwidth
Global ZImage:TPixmap'Zielimage
Global Format


Repeat

'Schritt 1: Auswahl des Images
   Local filter$="Bitmaps:bmp;PNG:png*"
   Local Selected:String = RequestFile ("Select File",filter,False,CurrentDir())
   If selected = "" End
   QImage:TPixmap = LoadPixmapPNG(Selected)
   If QImage=Null QImage:TPixmap = LoadPixmap(Selected)'Wenn es kein PNG ist, als BMP laden.
   If QImage=Null
      Print "Fehler: Konnte Image nicht laden."
      WaitKey()
      End
   EndIf
   Format = PixmapFormat(QImage)
   Qheight = PixmapHeight(QImage)
   Qwidth = PixmapWidth(QImage)
   Print "Imageheight: "+Qheight
   Print "Imagewidth: "+Qwidth
   
'Schritt 2: Erstellen des Isotiles
   DebugLog "Erstelle"

   ZImage = CreatePixmap(Qwidth*2,QHeight,PF_RGBA8888)
   For Local x = 0 To Qheight-1
   For Local y = 0 To Qwidth-1
      Local xnew = x+y
      Local ynew = (y-x+Qwidth-Qheight)/2
      WritePixel(ZImage,xnew,ynew+Qheight/2,ReadPixel(QImage,x,y))
   Next
   Next

   
'Schritt 3: Abspeichern des neuen Images
   DebugLog "Speichere"
   DrawPixmap(ZImage,0,0)
   Flip
   WaitKey()
   SavePixmapPNG(ZImage,Left(Selected,Len(Selected)-4)+".png",9)

   
   QImage = Null
   ZImage = Null
   FlushMem()

Forever


Beispiel:

user posted image
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image

Jan_

Ehemaliger Admin

BeitragMi, Okt 05, 2005 7:23
Antworten mit Zitat
Benutzer-Profile anzeigen
Hast du es schonmal unter Opengl probiert?
between angels and insects
 

klepto2

BeitragMi, Okt 05, 2005 8:54
Antworten mit Zitat
Benutzer-Profile anzeigen
Bei Mir funktioniert es, aber versuch einfach mal ein CLS einzufügen, bevor du deine PixMap zeichnest, dann sollte dieser effekt nicht mehr auftreten. Da bei manchen Treiberversion der Backbuffer nicht geleert wird(vorallem im Window Mode).
Matrix Screensaver
Console Modul für BlitzMax
KLPacker Modul für BlitzMax

HomePage : http://www.brsoftware.de.vu

Firstdeathmaker

BeitragMi, Okt 05, 2005 10:10
Antworten mit Zitat
Benutzer-Profile anzeigen
Jetzt sagt das Program, dass alles ok wäre (Process complete), aber es wird kein Image mehr erzeugt. Ich verstehe das nicht, der Debugger gibt noch aus "speichere", aber den nächsten Befehl, den Debugstop() führt er nicht mehr aus.

@ klepto2: Cls wirkt sich nicht so doll auf eine PixMap aus, das Problem liegt ja nicht darin, dass die Pixmap nicht eingezeichnet wird, sondern dass sie falsch erstellt wird.

@ Jan_: Mit OpenGl verschwindet das Problem auch nicht (Hab ich gerade ausprobiert)


'Isotilecreator by Christian Geißler
Strict

Graphics 400,300,0


Code: [AUSKLAPPEN]
Global QImage:TPixmap'Quellimage
Global Qheight,Qwidth
Global ZImage:TPixmap'Zielimage
Global Format


Repeat

'Schritt 1: Auswahl des Images
   Local filter$="Bitmaps:bmp;PNG:png*"
   Local Selected:String = RequestFile ("Select File",filter,False,CurrentDir())
   If selected = "" End
   QImage:TPixmap = LoadPixmapPNG(Selected)
   If QImage=Null QImage:TPixmap = LoadPixmap(Selected)'Wenn es kein PNG ist, als BMP laden.
   If QImage=Null
      Print "Fehler: Konnte Image nicht laden."
      WaitKey()
      End
   EndIf
   Format = PixmapFormat(QImage)
   Qheight = PixmapHeight(QImage)
   Qwidth = PixmapWidth(QImage)
   Print "Imageheight: "+Qheight
   Print "Imagewidth: "+Qwidth
   
'Schritt 2: Erstellen des Isotiles
   DebugLog "Erstelle"

   ZImage = CreatePixmap(Qwidth*2,QHeight,PF_RGBA8888)
   For Local x = 0 To Qwidth*2
   For Local y = 0 To Qheight
      WritePixel(ZImage,x,y,-1)
   Next
   Next

   For Local x = 0 To Qheight-1
   For Local y = 0 To Qwidth-1
      Local xnew = x+y
      Local ynew = (y-x+Qwidth-Qheight)/2
      WritePixel(ZImage,xnew,ynew+Qheight/2,ReadPixel(QImage,x,y))
   Next
   Next

   
'Schritt 3: Abspeichern des neuen Images
   FlushKeys()
   DebugLog "Speichere"
   DebugStop()
   DrawPixmap(ZImage,0,0)
   Flip
   WaitKey()
   SavePixmapPNG(ZImage,Left(Selected,Len(Selected)-4)+".png",5)

   
   QImage = Null
   ZImage = Null
   FlushMem()

Forever
www.illusion-games.de
Space War 3 | Space Race | Galaxy on Fire | Razoon
Gewinner des BCC #57 User posted image

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group