View previous topic :: View next topic |
Author |
Message |
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Tue Aug 19, 2014 2:33 am Post subject: Picture class |
|
|
Hi,
How could I load image form stream into a bitmap object?
I can load without any problems to an image by using this
Code: | img.picture.loadFromStream(findTableFile('image.png').Stream); |
Tried
Code: | bmp = createPicture();
bmp.loadFromStream(findTableFile('image.png').Stream);
img.Canvas.draw(0,0,bmp.getBitmap()); |
But It does not return the full size...
I want to re-use the same bitmap over and over to avoid bugs and glitches I occurred before by creating thousands objects in few minutes.
_________________
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Aug 19, 2014 11:00 am Post subject: |
|
|
Code: | img = createImage(nil)
fileStream = findTableFile('image.png').Stream
img.Picture.loadFromStream(fileStream)
-- other images
for i=1,6 do
UDF1['CEImage'..i].Width = img.Picture.Bitmap.Width
UDF1['CEImage'..i].Height = img.Picture.Bitmap.Height
UDF1['CEImage'..i].setPicture(img.Picture)
end
UDF1.show()
img.destroy() |
Of course you have to create UDF1 form with six CEImage objects.
_________________
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Tue Aug 19, 2014 11:40 am Post subject: |
|
|
Well thanks as this get the work done.
_________________
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Wed Aug 20, 2014 6:46 am Post subject: |
|
|
Hey mgr.inz.Player,
It seems that I cannot draw on bitmap if I load image from stream.
I've made a script in my server that converts thumbs to rgb tables.
And based on the game there's a image as background.
Since the image as small background cannot change or will not be changed I want to load it from stream (better performance and faster start up).
So I load it up like this
Code: | image.picture.loadFromStream(findTableFile(bgr_objects[object_type]).Stream); |
And then run a timer that checks if the native thread loaded and create a bitmap with the image and if it does it draws it on.
I draw it like this
Code: | image.picture.Bitmap.Canvas.draw(5,5,thumbs[id]); |
But it does not seem to be visible, I can't draw even a text.
So is there any solution for it? or any option to load image from stream directly to a bitmap?
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Wed Aug 20, 2014 7:10 am Post subject: |
|
|
Try picture.PNG.canvas
or picture.canvas
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Wed Aug 20, 2014 8:18 am Post subject: |
|
|
Dark Byte wrote: | Try picture.PNG.canvas
or picture.canvas |
It works as long as there is no transparency at all?
I've tried it first with the wanted image, it seems that everything I try (fill rect, text out and etc.) makes the affected area go transparent?
Attached a CT to demonstrate.
3 images
1. of the normal image
2. half transparent object (to show that the drawing on the image makes it go transparent and not a solid color)
3. the image where I load into the image from the stream and try to draw on it.
Well I'd rather to be able load an image from stream to a bitmap or directly to canvas (as it seems that I can only via the picture class).
EDIT:
Strange if I do this following:
UDF1 -> Edit
Execute the script, close the editor
UDF1-> show
It'll display it the way it is suppose to.
Description: |
|
Download |
Filename: |
picture class.CT |
Filesize: |
114.02 KB |
Downloaded: |
639 Time(s) |
_________________
|
|
Back to top |
|
|
|