Same color using writepixel vs plot
BlitzMax Forums/BlitzMax Beginners Area/Same color using writepixel vs plot
| ||
| Given... pixcolor="some long integer" pixred=(pixcolor & $00FF0000) Shr 16 pixgreen=(pixcolor & $FF00) Shr 8 pixblue=(pixcolor & $FF) If I did... writepixel SomePixMap,0,0,pixcolor and... setcolor pixred,pixgreen,pixblue now... If I did a plot 0,0 or... DrawPixmap SomePixMap,0,0 would this "always" (endian) result in the same color on screen? If not, how could I make sure it will? [edit] And how about, if I used an image instead of a PixMap? |
| ||
| You can only writepixel to a pixmap so you'd have to lock the image to get a pixmap and then convert back to an image. However, the colours for writepixel and setcolor should be the same. I *think* it's possible the colour might not be exactly the same as the same RGB values in a paint package if you're using a 'shallower' colour depth in BMax. However, the ARGB converted to R,G,B and setcolor should always be the same. This *might* make sense...
Graphics 640 , 480
SetColor 100 , 100 , 100
DrawRect 0,0,100,100
mypixmap:TPixmap = GrabPixmap(0 , 0 , 100 , 100)
Cls
DrawPixmap mypixmap,0,0
For x = 0 To 99
For y = 0 To 99
WritePixel(mypixmap , x , y , intcolour(50 , 255 , 100))
Next
Next
DrawPixmap mypixmap , 100 , 0
SetColor 50,255,100
For x = 0 To 99
For y = 0 To 99
Plot 200 + x , y
Next
Next
SetColor 255,255,255
myimage:TImage = LoadImage(mypixmap)
DrawImage myimage , 300 , 0
DrawText "Orig pixmap" , 0,110
DrawText "Pixmap" , 100,110
DrawText "Plot " , 200,110
DrawText "Pix2image", 300,110
Flip
WaitKey()
Function intcolour(r , g , b , a = 255)
Return A Shl 24 | R Shl 16 | G Shl 8 | B Shl 0
End Function
and this is a bit overkill...
Graphics 640 , 480
SetColor 100 , 100 , 100
DrawRect 0,0,100,100
mypixmap:TPixmap = GrabPixmap(0 , 0 , 100 , 100)
For r = 0 To 255 Step 16
For g = 0 To 255 Step 16
For b = 0 To 255 Step 16
Cls
For x = 0 To 99
For y = 0 To 99
WritePixel(mypixmap , x , y , intcolour(r,g,b))
Next
Next
DrawPixmap mypixmap , 100 , 0
SetColor r,g,b
For x = 0 To 99
For y = 0 To 99
Plot 200 + x , y
Next
Next
SetColor 255,255,255
myimage:TImage = LoadImage(mypixmap)
DrawImage myimage , 300 , 0
DrawText "Pixmap" , 100,110
DrawText "Plot " , 200,110
DrawText "Pix2image", 300,110
Flip
Next
Next
Next
Function intcolour(r , g , b , a = 255)
Return A Shl 24 | R Shl 16 | G Shl 8 | B Shl 0
End Function
|
| ||
| void post |
| ||
| So I don't have to mind: PixmapFormat? As used in this fadeRoutine? http://blitzbasic.com/codearcs/codearcs.php?code=1282 |
| ||
| Not if you're using standard loadpixmap, grabpixmap, lockimage etc. <edit> If you're worried you can always use pixmapconvert to get a 'standard' format. |
| ||
| Ah, Thanks! I thought I knew how it works, but the info on PixMapFormat drove me of course! "I must try to think simple thoughts!" :) [edit] Erm... [<edit> If you're worried you can always use pixmapconvert to get a 'standard' format.] Please don't make me doubt! |
| ||
| What is it you want to do? If you want to access pixmaps in memory then you will need to take the pixmapformat into account. However, the Bmax functions do this for you. Writepixel, for instance, will check the format and write as appropriate. |
| ||
| I want to keep colours as long integers in an an array. (I used Readpixel to collect them from some PixMap) Use Writepixel to a Pixmap while I'm in Guimax-mode. Then, when I'm in Graphics-mode(after Graphics 800,600), I use DrawPixmap to copy the picture to the backbuffer. Then I want to use Plot to draw the same colours to that picture. To go back to Guimax-mode I want to use GrabPixmap. "Unless there is a much better way to do this kind of stuff ofcourse :)" [edit] I stumbled in a thread where XLSIOR wrote: "Except you can't actually *count* on the backbuffer not getting cleared by the driver, so there is no guarantee that you still see the 'unaffected' areas on the screen. In addition to that, some video adapters alternate between multiple backbuffers, meaning you need to account for all movement during the last *couple* of frames if you choose not to redraw the entire screen... Not just the last one." If I understand this correctly, it is not wise to just overwrite portions of the backbuffer, because one can not be sure that the parts that are NOT" overwritten are still visable when the screen is "Flipped". If this is the case, then my question in this thread is meaningless. But Drawing the whole screen via DrawPixMap to the backbuffer each frame would be so much slower then just a couple of pixels. Can somebody please clear up my mind? p.s. I want my AMIGA back! |