eleria Posted May 25, 2008 Posted May 25, 2008 (edited) Hi guys I decided to try prospeed API because with Autoi GDI+ api I didn't manage to have a fluid display a buffered image while moving around the edges of the screen (when the GUI is partly out of the screen it simply eats your CPU and can flicker at times) (Also I can't write text very fast with GDI+ with stable performances : /) But sadly using prospeed to ImportPNG then PaintPNG performances are even worse... (much flickering!) No examples on the prospeed UDF site handle draging the window, much less around the edges of the screen... So I was wondering if you guys know a way to paint a background and stuff on it and refresh that when WM_PAINT messages are received without all those problems? Edited May 25, 2008 by eleria
jpam Posted May 25, 2008 Posted May 25, 2008 post some example code so i can see what u are doing wrong
eleria Posted May 25, 2008 Author Posted May 25, 2008 (edited) $testhdc = GetHDC() $import = ImportPNG(1,"background.png") PaintPng(1, $testhdc, 0, 0, $import, 0)And then PaintPng(1, $testhdc, 0, 0, $import, 0)At every WM_Paint event except the first since during the first $testdc has no value yet...And when dragging the window when it isn 't completely inside the screen it flickers and it is jaggyA portion of my script is still drawing using the GDI+ UDF since for the moment I can't assure fluid movement with only a background to be drawn (I want to draw many sprites depending on coordinates I extract from a database...) Edited May 25, 2008 by eleria
jpam Posted May 25, 2008 Posted May 25, 2008 try it this way, #include <prospeed30.au3> Opt("GUIOnEventMode", 1) GUICreate("", 800, 600) GUISetOnEvent(-3, "_exit") GUISetState() $hdc = GetHDC() CreateBuffer(800,600) ; create buffer for WM_PAINT $pic = CreateImage(800,600) ; Create empry bitmap $png = ImportPng(0,"animal.png") ; import png image PaintPng(0,$pic,0,0,$png,0) ; paint png image to empty bitmap PaintImage($hdc,0,0,800,600,$pic,0,0,0) ; paint bitmap to window SetBuffer($pic) ; set screenbuffer with bitmap , can allso with hDC While 1 Sleep(1000) WEnd Func _exit() Exit EndFunc
eleria Posted May 25, 2008 Author Posted May 25, 2008 Well this crashes even when executed separately : /
eleria Posted May 25, 2008 Author Posted May 25, 2008 (edited) Yes I most certainly do EDIT : Ok DLL wasn't in the directory, but anyway moving window produces jagginess around the edges of the screen Is Windows not meant to display window contents while moving at all? Or maybe only feasible with directx/draw? Edited May 25, 2008 by eleria
jpam Posted May 25, 2008 Posted May 25, 2008 try to move a explorer window , if it has the same jagginess then your videodrivers are not installed properly. its strange because i dont have any problems overhere
eleria Posted May 25, 2008 Author Posted May 25, 2008 (edited) Only a very small flickering trail occur on any other program when moving inside/outside the desktop area. Even some small blocks out of the window are drawn a bit late when moving at a normal speed with prospeed : / EDIT : But hey I could live without it... What I would like to know is if I need to draw sprites and text ontop, where would I put that part inside your example? Edited May 25, 2008 by eleria
jpam Posted May 25, 2008 Posted May 25, 2008 what gdi functions do you use in your script ? otherwise send me a pm with your script so i can look at it
jpam Posted May 25, 2008 Posted May 25, 2008 sprites need a screenbuffer , so if you want to draw sprites it should be after setbuffer() text needs hdc or a bitmap to draw to
eleria Posted May 25, 2008 Author Posted May 25, 2008 Well thank you alot for your help, I'm gonna try and work something out by myself and learn abit more before bothering you again ^^"
eleria Posted May 26, 2008 Author Posted May 26, 2008 (edited) Back to some questioning Is it possible once I've loaded a sprite to alter it's color values? It would spare me the need to create a variable number of sprites with different colours... (I can't know in advance how many different colour I need because It depends on data I fetch from sql) Or I would still need to draw with the standard GDI+ UDF ... T_T Edited May 26, 2008 by eleria
jpam Posted May 26, 2008 Posted May 26, 2008 (edited) You can change the sprite picture as much as you want $spritePic = LoadFileImage("plane.jpg") $fx = InitFX($spritePic) ExchangeRgb($spritePic,0,0,$fx,50,0,0) $sprite = sprite($spritePic, $hdc, 0, 0, 100, 100, 1, 1, 1, 50, 50) Edited May 26, 2008 by jpam
eleria Posted May 26, 2008 Author Posted May 26, 2008 (edited) Well it seems that when I use your transformation on my sprites they take a weird rainbow colour (even if I copy exactly what you suggested) And also window redrawing seems to take a while when my 200-800 sprites are loaded I tried with both png and bmp EDIT: after a few tries, it seems that when using ExchangeRgb it only works when I put the same numbers for R & G & B Edited May 26, 2008 by eleria
jpam Posted May 26, 2008 Posted May 26, 2008 eleria said: my 200-800 sprites are loaded200 to 800 sprites man , you need a fast computer to draw so many sprites on screen at ones !can you send me your sprite bitmap, so i can test with it ?
eleria Posted May 26, 2008 Author Posted May 26, 2008 (edited) Sent the image to you. But sprites fllickering almost the same when there is one and when there is 200 ^^" I can make so that there is no flickering by doing Sprite to Background but the problem is that I want that when the user selects a certain option only some sprites get drawn... Edited May 26, 2008 by eleria
jpam Posted May 26, 2008 Posted May 26, 2008 (edited) first problem is when you create a array from your bitmap it must can be divided by 4, otherwise you get strange results so i created a new one 8x8 and copied your sprite picture in it. second problem is when you use a not animated sprite ,you have to set the $S_FRAMES and $S_START_FRAME to 1 when you create a sprite. Sprite($S_Spriteplane, $S_Destination, $S_offsetX, $S_offsetY, $S_WIDTH, $S_HEIGHT, $S_FRAMES, $S_START_FRAME, $S_FRAME_SPEED, $S_posX, $S_posY) example creates 400 sprites and changing colors i attached the new sprite below. #include <Prospeed30.au3> Opt("GUIOnEventMode", 1) HotKeySet("{Esc}","_Exit") GUICreate("Sprite FX", 600, 400) GUISetOnEvent(-3, "_exit") GUISetState() $back = Background("autoit_builder_wall_800x600.jpg", 0, 0, 600, 400) $load = LoadFileImage("msg-24989-1211826305.png") $fx = InitFx($load) Dim $sprite[401] For $i = 1 To 400 $sprite[$i] = sprite($load, $HDC, 0, 0, 8, 8, 1, 1, 1, Random(0,600,1), Random(0,400,1)) Next While 1 ExchangeRgb($load,0,0,$fx,0,100,0) Sleep(500) ExchangeRgb($load,0,0,$fx,0,-100,0) Sleep(500) ExchangeRgb($load,0,0,$fx,100,0,0) Sleep(500) ExchangeRgb($load,0,0,$fx,-100,0,0) Sleep(500) WEnd Func _exit() FreeAllImages() deleteallsprites() Exit EndFunc Edited May 26, 2008 by jpam
eleria Posted May 27, 2008 Author Posted May 27, 2008 (edited) Slowly getting there I think but still... But strangely sometimes sprites get drawn partly, some other times they appear as squares filled with one colour See my attachment for a view of the scrambled display I get This is my loop code : dim $drawx[$total], $drawy[$total], $sprite[$total] For $g = 0 TO ($total-1) $seedR = random(55,255,1) $seedG = random(55,255,1) $seedB = random(55,255,1) $drawx[$g] = Floor(BitShift($xx[$g], 5)) $drawy[$g] = Floor(($yy[$g]) / 45.5) ExchangeRgb($spritePic,0,0,$fx,$seedR,$seedG,$seedB) $sprite[$g] = sprite($spritePic, $hdc, 0, 0, 8, 8, 1, 1, 1, $drawx[$g], $drawy[$g]) SpriteToHDC($sprite[$g]) ExchangeRgb($spritePic,0,0,$fx,"-"&$seedR,"-"&$seedG,"-"&$seedB) Next DeleteAllSprites() Edited May 27, 2008 by eleria
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now