[ solved ] big bmp ?

General FreeBASIC programming questions.
Post Reply
bluatigro
Posts: 660
Joined: Apr 25, 2012 10:35
Location: netherlands

[ solved ] big bmp ?

Post by bluatigro »

this goes wrong . why ?

Code: Select all

''bluatigro 19 jun 2017
''test big bmp

dim as any ptr img4k = imagecreate( 3840 , 2160 )

bsave "bmp\big.bmp" , img4k
Last edited by bluatigro on Jun 20, 2017 8:12, edited 1 time in total.
fxm
Moderator
Posts: 12131
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: big bmp ?

Post by fxm »

ImageCreate must be called after graphic mode initialization, else it returns 0.
bluatigro
Posts: 660
Joined: Apr 25, 2012 10:35
Location: netherlands

Re: big bmp ?

Post by bluatigro »

@ fxm :
thanks that worked

Code: Select all

''bluatigro 19 jun 2017
''test big bmp

screen 20 , 32

dim as any ptr img4k = imagecreate( 3840 , 2160 )

bsave "bmp\big.bmp" , img4k
big.bmp = 24.301 kb

test complete : it is posible to create verry big bmp's
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: [ solved ] big bmp ?

Post by dodicat »

You can also create an array suitable to contain a bitmap.

Code: Select all

 

#Include "file.bi"

'use for texturing colours within range 0 to 255
function map(a as single,b as single,x as single,c as single,d as single) as Single
 Return ((d)-(c))*((x)-(a))/((b)-(a))+(c)
End function

dim as long wide,high

wide=800
high=600

ReDim as ulong a((wide+1)*(high+1)) 'A proposed 32 bit bitmap

'set the basic information so a() will be a bitmap. 
a(0)=7           'must be 7
a(1)=4           'size of ulong for 32 bit colour
a(2)=wide        'width
a(3)=high        'height
a(4)=a(1)*a(2)   'pitch
a(5)=0           
a(6)=0
a(7)=0

'add some texture to the array, starting at element 8
for n as long=8 to ubound(a)
	Var r=map(8,UBound(a),n,0,255)
	Var g=map(8,UBound(a),n,255,0)
	Var b=iif(r>g,0,255)
    a(n)=rgb(r,g,b) 'give these elemnts a ulong colour.
next n

Screen 20,32

BSave("screen.bmp",@a(0))
If FileExists ("screen.bmp") Then BLoad "screen.bmp":Kill "screen.bmp" Else Print "ERROR"
Sleep


 
Post Reply