saving image bigger than screen..

BlitzMax Forums/BlitzMax Programming/saving image bigger than screen..

gameproducer(Posted 2011) [#1]
I'm doing a program which makes it possible to generate playing card art from defined text & image files.

I'd like to do the following:
- draw stuff on screen/buffer in bmax
- save all drawn stuff as png image (1050 x 1450 size)

I'm aware of the following:
Local img:TPixmap = GrabPixmap(0, 0, Self._cardWidth, Self._cardHeight)
SavePixmapPNG(img, "../deck-processed/" + filename, Self._compression)


I have 1050 x 1450 card background image which I draw on screen, but part of it gets clipped off. When I save, all pixels under about 1080ish or so are black. My desktop resolution is 1920 x 1080.

I tried to set bigger viewport:
Local resolutionY:Int = 1450
Local resolutionX:Int = 1050
Graphics(resolutionX, resolutionY)

SetViewport(0, 0, resolutionX * 2, resolutionY * 2)


But it didn't do anything good even though it says that setViewport defines what gets clipped.

Looks like for some reason everything bigger than my screen resolution gets clipped.

Any ideas for solutions on how to save bigger PNG than screen resolution allows?

(I already rendered my card art 90 degrees rotated, this way I got 1450x1050 images exported, which I can then rotate in Windows... but it's bit lame :))


GfK(Posted 2011) [#2]
Why can't you just create the images in a pixmap, avoiding the need to use GrabPixmap()? Granted it won't be particularly fast, but it'll work and it'll be completely independent of any graphics object.

There is code in the code archives to draw one pixmap onto another while retaining alpha. Other than that you can use pixmap.paste().

[edit] Also, why do they need to be so big?

Last edited 2011


gameproducer(Posted 2011) [#3]
"create the images in a pixmap"... you mean, instead of "LoadImage" use "LoadPixmapPNG"? (+archive code, I guess it's this: http://www.blitzbasic.com/codearcs/codearcs.php?code=2658)

I have existing "deck-background.png" which I need to load.

Then I also need font (using "loadImageFont("impact.ttf"....) which is needed to write stuff on cards. How could I do this with pixmap?

What pixmap.paste(source, x,y) does?

And cards need to be (at least) this big since they are used to print physical products. Smaller images would mean poorer quality on printed products.


AdamRedwoods(Posted 2011) [#4]
Avoid doing it through the onscreen method (although you could use an FBO ), and work directly with Pixmaps.

1. If all you want is to paste new images onto a Pixmap, there's a simple way to do this if you search the code archives: PixmapOnPixmap.
There are several libraries, I'd use the one where they offer scaling and rotation built in. Since fonts are just images, this could be a solution.
http://blitzmax.com/codearcs/codearcs.php?code=2411

2. Creating graphics directly to Pixmaps is a bigger task. There are some libraries out there, but I would recommend learning how to work with Cairo, and use Brucey's Cairo wrapper. It'll take work, but not impossible.


Oddball(Posted 2011) [#5]
gameproducer wrote:
And cards need to be (at least) this big since they are used to print physical products. Smaller images would mean poorer quality on printed products.
Then why don't you just use Photoshop or equivalent?

Last edited 2011


gameproducer(Posted 2011) [#6]
Thanks guys.

@Adam: I try that #1.

@Oddball: I did that for the first run of the deck, it took quite a bit of time. Changing texts in one external file is easier/faster than going through 100-150 layers.


Pete Rigz(Posted 2011) [#7]
I had to overcome this in TimelineFX because some people wanted to save animation frames larger then 512x512. My way round it was pretty simple, I just grabbed the visible screen into a pixmap and pasted that into the larger pixmap, then rendered the screen again but offset the image to draw the rest on the screen and grabbed the rest and pasted that into the larger pixmap and so on as many times as is necessary.

But if you don't need any of the opengl/directx drawing stuff, like alpha blending and what-not then it might just be easier for you to work directly with pixmaps as was mentioned.


gameproducer(Posted 2011) [#8]
I need alpha, and Pete - I just got the same idea before reading your text. In my case, this will be the best way to do it.

Thanks everybody again.


Jesse(Posted 2011) [#9]
if they are just images why don't you paste directly to a pixmap?
local destPixmap:Tpixmap = CreatePixmap(resolutionX,resolutiony,PF_RGBA8888)
local sourcePixmap:Tpixmap = LockImage(cardImg)
destpixmap.paste(sourcepixmap,x,y)


Last edited 2011

Last edited 2011


gameproducer(Posted 2011) [#10]
because I need text as well, and pixmaps won't retain alpha. So, this is easiest & bestest solution for me to draw few screens, grab pixmaps, combine grabbed to one big pixmap and save as png.


Jesse(Posted 2011) [#11]
acutally it's the other way around. GrabPixmap don't retain alpha. It's added to it as 255 regardless of what it used to be.
text can also be pasted to pixmap just not rotated. You just need to know how it works:
http://www.blitzbasic.com/codearcs/codearcs.php?code=2736

Last edited 2011


gameproducer(Posted 2011) [#12]
Ah, well, not needing that anymore unless current method gets slow, but thanks for the link. Perhaps helps someone else.

This one is working perfectly now.

Last edited 2011