[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

obsolete[LuaStudio] Two images

! String methodsFor: 'platform-io' !
fileContents
	" Return the contents of file stored at fileName given by the receiver.
	Return nil if the file do not exist.
	"

	^# #read: self! !


! Bitmap class methodsFor: #samples !
twoImagesExample
	" Two images example "
	
	| target data bmp bytes |
	target := Display stage.

	data := BitmapData 
		bytes: (Lib project getBytes: '/assets/Image.jpg') 
		rawAlpha: nil.
	bmp := (Bitmap 
		bitmapData: data 
		pixelSnapping: PixelSnapping auto
		smoothing: false)
		alpha: 0.5; x: 0; y: 0; 
		yourself.
	self print: 'bmp height=', bmp height.
	self print: 'bmp width=', bmp width.
	bmp width: bmp width * ((Capabilities screenResolutionX / 2) / bmp width).
	bmp height: bmp height * ((Capabilities screenResolutionY) / bmp height).
	target addChild: bmp. 

	data := BitmapData 
		bytes: (ByteArray fromBytes: (IOFile new getBytes: 'C:/LUA/luaStudio/LuaStudio_v1_6_0_Win/LuaStudio/assets/Image.jpg')) 
		rawAlpha: nil.
	bmp := (Bitmap 
		bitmapData: data 
		pixelSnapping: PixelSnapping auto
		smoothing: false)
		alpha: 0.5; x: Capabilities screenResolutionX / 2; y: 0; 
		yourself.
	bmp width: bmp width * ((Capabilities screenResolutionX / 2) / bmp width).
	bmp height: bmp height * ((Capabilities screenResolutionY) / bmp height).
	target addChild: bmp.! !
	
! Bitmap class methodsFor: #samples !
scaleBitmap: bitmap
	" Answer bitmap scaled "
	
	bitmap width: bitmap width * ((Capabilities screenResolutionX / 2) / bitmap width).
	bitmap height: bitmap height * ((Capabilities screenResolutionY) / bitmap height).
	! !
! !
	
! Bitmap class methodsFor: #samples !
scaleBitmap: bitmap
	" Answer bitmap scaled "
	
	bitmap width: bitmap width * ((Capabilities screenResolutionX / 2) / bitmap width).
	bitmap height: bitmap height * ((Capabilities screenResolutionY) / bitmap height).
	! !


Bitmap twoImagesExample


Issues:
I tried to use Bytes>>ofString: aString, in order to get data with full path and with relative path (using #fileContents):
self cancelFileIn!
	string := 'assets/Image.jpg' fileContents.
	bytes := Bytes ofString: 'assets/Image.jpg' fileContents. 

then do: 

	data := BitmapData 
		bytes: bytes
		rawAlpha: nil.
	bmp := Bitmap 
		bitmapData: data
		....
	target addChild: bmp.

but I didn't work.
|