Compiller für DOS Grafik (bildschirmtiefe...)
Verfasst: 01.10.2004 15:41
Es geht um folgendes:
Ich habe ein Programm mit QBasic gemacht (gehört zwar nicht hier rein, aber das problem liegt ja bei Pure Basic), das Bilder lesen und schreiben kann, indem es von jedem Punkt den Farbwert ließt.
Das programm sieht so aus:
(im Moment zeichnet es für Testzwecke die 256 verwendbaren Farben)
so, jetzt möchte ich normale Bitmaps in dieses "Grafikformat" compilieren, das geht aber schlecht!
Ich hab dafür dieses Programm gemacht:
( Datei http://mitglied.lycos.de/benpicco/Palette.bmp benötigt.
Das programm sieht so aus:
Es schreibt aber nicht alle 256 Farben wieder hin!(wenn ich z.b. palette.bmp) compilieren will. mit unterschiedlichen Farbtiefen wird´s scheinbar auch nix...
Help me!!!
Ich habe ein Programm mit QBasic gemacht (gehört zwar nicht hier rein, aber das problem liegt ja bei Pure Basic), das Bilder lesen und schreiben kann, indem es von jedem Punkt den Farbwert ließt.
Das programm sieht so aus:
Code: Alles auswählen
1 :
'$DYNAMIC
DIM code1%(32000)
DIM Code2%(32000)
Z# = 1
CLS
SCREEN 0
PRINT "Load => 1"
PRINT "Draw => 2"
INPUT "", choice
SELECT CASE choice
CASE 1: GOTO load
CASE 2: GOTO pic
CASE ELSE: GOTO 1
END SELECT
pic:
INPUT "What should be the name of the saved file? ", file$
SCREEN 13
CLS
Z = 0
FOR Y = 1 TO 200
FOR X = 1 TO 320
IF Z > 256 THEN
GOTO weiter
END IF
PSET (X, Y), Z
Z = Z + 1
weiter:
'PSET (X, Y), INT(256 * RND)
'CIRCLE (INT(X * RND), INT(Y * RND)), INT(100 * RND), INT(256 * RND)
NEXT
Z = 0
NEXT
RANDOMIZE TIMER
SLEEP
Z# = 0
FOR Y = 1 TO 200
FOR X = 1 TO 320
Z# = Z# + 1
'LOCATE 1, 1: PRINT Z#
IF UBOUND(code1%) >= Z# THEN
code1%(Z#) = POINT(X, Y)
ELSE
M# = Z# - 32000
Code2%(M#) = POINT(X, Y)
END IF
NEXT
NEXT
Z# = 0
M# = 0
OPEN file$ FOR OUTPUT AS #1
FOR Y = 1 TO 200
FOR X = 1 TO 320
Z# = Z# + 1
IF UBOUND(code1%) >= Z# THEN
WRITE #1, code1%(Z#)
ELSE
M# = Z# - 32000
WRITE #1, Code2%(M#)
END IF
NEXT
NEXT
CLOSE #1
PRINT "Done!"
SLEEP
END
load:
INPUT "insert file name ", file$
SCREEN 13
LOCATE 10, 10: PRINT "loading"
OPEN file$ FOR INPUT AS #1
FOR Z# = 1 TO 32000
INPUT #1, code1%(Z#)
'LOCATE 1, 1: PRINT code1%(Z#)
NEXT
FOR M# = 1 TO 32000
INPUT #1, Code2%(M#)
'LOCATE 1, 1: PRINT Code2%(M#)
NEXT
CLS
Z# = 0
M# = 0
FOR Y = 1 TO 200
FOR X = 1 TO 320
Z# = Z# + 1
IF UBOUND(code1%) >= Z# THEN
col% = code1%(Z#)
PSET (X, Y), col%
ELSE
M# = Z# - 32000
PSET (X, Y), Code2%(M#)
END IF
NEXT
NEXT
SLEEP
END
so, jetzt möchte ich normale Bitmaps in dieses "Grafikformat" compilieren, das geht aber schlecht!
Ich hab dafür dieses Programm gemacht:
( Datei http://mitglied.lycos.de/benpicco/Palette.bmp benötigt.
Das programm sieht so aus:
Code: Alles auswählen
InitSprite()
InitKeyboard()
InitMouse()
InitPalette()
LoadPalette(1,"Palette.bmp")
UseJPEGImageDecoder()
UsePNGImageDecoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()
Global Datei.s
Dim farbe.w(256)
Dim Farbwert.w(640000)
Global Z.l
Global X.w
Global Y.w
Global name.s
Global q.w
q = 0
; PureBasic Visual Designer v3.90 build 1360
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- MenuBar Constants
;
Enumeration
#MenuBar_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Text_0
#Datawahl
#Vorschau
#start
#ProgressBar_1
#name
EndEnumeration
;- Image Plugins
;- Image Globals
Global Image0
Procedure Open_Window_0()
If OpenWindow(#Window_0, 284, 199, 450, 230, #PB_Window_MinimizeGadget | #PB_Window_SizeGadget , "Bitmap to DOS compiler")
If CreateMenu(#MenuBar_0, WindowID())
MenuTitle("")
EndIf
If CreateGadgetList(WindowID())
TextGadget(#Text_0, 10, 10, 280, 20, "Datei zum compilieren für DOS grafik auswählen")
TextGadget(10, 10, 10, 280, 50, "Lade Daten...")
ExplorerTreeGadget(#Datawahl, 10, 40, 280, 110 , "*.bmp;*.jpg;*.png;*.tga;*.tff", #PB_Explorer_AlwaysShowSelection | #PB_Explorer_AutoSort)
ImageGadget(#Vorschau, 310, 40, 110, 110, "", #PB_Image_Border)
ButtonGadget(#start, 240, 170, 80, 30, "Compile it!")
StringGadget(#name, 10, 170, 220, 20, "Dateiname Eingeben")
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventMenu
;Debug "WindowID: " + Str(EventWindowID())
MenuID = EventMenuID()
EndIf
If Event = #PB_EventGadget
;Debug "WindowID: " + Str(EventWindowID())
GadgetID = EventGadgetID()
If GadgetID = #Datawahl
If GetGadgetState(#Datawahl) = 1
CreateImage(0, 110, 110)
LoadImage(0,GetGadgetText(#Datawahl))
StartDrawing(WindowOutput())
ImageGadget(#Vorschau,310, 40, 110 , 110, 0, #PB_Image_Border)
DrawImage(UseImage(0),310, 40,110,110)
StopDrawing()
EndIf
ElseIf GadgetID = #start
If GetGadgetState(#Datawahl) = 1
Datei = GetGadgetText(#Datawahl)
name = GetGadgetText(#name)+".bpc"
Event = #PB_EventCloseWindow
Goto selected
EndIf
EndIf
EndIf
Until Event = #PB_EventCloseWindow
End
selected:
OpenScreen(320,200,32,"Bitmapcompiler")
LoadImage(1,"Palette.bmp")
StartDrawing(ScreenOutput())
DrawImage(UseImage(1),0,0)
For q = 0 To 255
farbe(q) = Point(q,0)
Next
StopDrawing()
FlipBuffers()
CloseScreen()
OpenScreen(320,200,32,"Bitmapcompiler")
StartDrawing(ScreenOutput())
UseImage(0)
If ImageHeight() > 200
ResizeImage(0, ImageWidth(),200)
EndIf
If ImageWidth() > 320
ResizeImage(0,320 ,ImageHeight())
EndIf
;DrawImage(UseImage(0),0,0)
;Locate(100,100):DrawText("Compiling... please wait")
;FlipBuffers()
DrawImage(UseImage(0),1, 1)
Z = 0
For Y = 1 To 200
For X = 1 To 320
Z = Z +1
For q = 0 To 255
If farbe(q)=Point(X,Y)
Farbwert(Z) = q
Goto weiter
EndIf
Next
weiter:
Next
Next
StopDrawing()
FlipBuffers()
CreateFile(0, name)
OpenFile(0,name)
UseFile(0)
For Z = 1 To 64010
WriteStringN(Str(Farbwert(Z)))
Next
CloseFile(0)
CloseScreen()
;MessageRequester("Fehler","Konnte Datei nicht speichern",0)
MessageRequester("Fertig!","Die datei wurde unter dem Namen "+name+" gespeichert!",0)
End
Help me!!!