SetScale DrawPixmap

BlitzMax Forums/BlitzMax Programming/SetScale DrawPixmap

BLaBZ(Posted 2012) [#1]
I set the scale before drawing my pixmap but it's not scaling.

SetScale(0.4, 0.4)
DrawPixmap(Pixmap, Self.x, Self.y)


Last edited 2012


col(Posted 2012) [#2]
Thats correct. A Pixmap is pixel data stored in CPU memory so it just gets drawn as it is stored. You can use ResizePixmap([...]) to resize. The speed of operation will depend on the CPU not the GPU.

Images are scaled using SetScale([..]). You could pass the pixmap to CreateImage, which is then loaded to the GPU and you can then scale from there. Scaling will then be done on the GPU.

Last edited 2012


skidracer(Posted 2012) [#3]
I think you mean LoadImage not CreateImage.


ima747(Posted 2012) [#4]
SetScale does not affect pixmap commands. Nor does rotation, origin, color, alpha or any other things that affect image drawing. The documentation is a bit unclear but if you read between the lines it's in there.



Images

Images are pre-rendered chunks of graphics that can be efficiently drawn using a single DrawImage command. Images are typically stored in png, bmp or jpg format, and can be loaded using the LoadImage command.

Image drawing is also affected by color, alpha, blend, rotation and scale. The current color is multiplied with each pixel color before the image is drawn to the backbuffer, allowing you to tint images. To disable this effect, you should set the current color to white.

Images can also have a mask color. This is the color that represents transparency when an image is drawn using the MASKBLEND blend mode. To set the mask color, use the SetMaskColor command.

Images can be created by snapshotting regions of the back buffer using the GrabImage command.


Pixmaps

Pixmaps are used to manipulate images at a pixel level, see the pixmaps module for details.
LockImage allows for direct Image pixel access and requires a corresponding call to UnlockImage when you have have finished reading or modifying the pixels. The DrawPixmap and GrabPixmap commands allow you to move pixels to and from the current graphic display's backbuffer.


Images are affected by things, pixmaps don't say they are affected by things and therefore they aren't. Extra confusion comes because the scale/rotate/etc. documentation says it affects "drawing commands" but in reality it only affects drawimage, not drawpixmap, drawline, etc.

There are basically 2 classes of drawing commands. Direct such as the vector commands (drawline, etc.) which includes drawpixmap, and then the fully graphics card handled drawimage and associatated modification commands. General rule, unless you really need to draw a pixmap, use an image. And even then depending on how/what you're doing it might be faster/easier to convert the pixmap to an image and then draw that image instead of the pixmap directly...