Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / reading and writing memblocks

Author
Message
smerf
12
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 14th Jan 2017 20:26
using dbpro

been using darkasic for a while but have stayed away from memblocks and arrays as much as possible. However I have to use them for my new project but im not really sure where to start
I want to make a memblock from an image and then read the memblock and recreate the image from the data, im making a paint kind of program where switching bitmaps and and reading pixels is to slow for smooth drawing.
im drawing pixels to 1 bitmap reading them then recreating them on another so I can have a scaled version but my max fps is about 34 fps. just need an bare bones basic example of reading pixel data and writing it to memblock. any help is appreciated.
A child's dream never dies.





Attachments

Login to view attachments
Derek Darkly
5
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 17th Jan 2017 00:52
Hello Smerf!

There is a memblock image example on This Thread regarding Matrixes and Heightmaps.
Hope it suffices!
Send your parents to noisy sprite demo hell... enter the D-Zone
smerf
12
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 17th Jan 2017 04:41 Edited at: 17th Jan 2017 04:43
That code is actually over complicated for me since i don't understand the basics behind memblocks. What is in the bytes were reading? how many bytes represent a pixel, are the colors included in this byte if so how do we grab them separately.
your code is reading from grey scale and grabbing no color data as far as i can tell


your code + Code Snippet



the tear down of your code + Code Snippet
what do we do with this date and how do we get color? super beginner with memory handling mate
A child's dream never dies.





Kevin Picone
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 17th Jan 2017 05:18

The colour data for each pixel in the mem blocks is made up of 4 bytes. So there's byte that represent the for Alpha level, a byte for RED level, a byte for GREEN level and one for BLUE.






PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
smerf
12
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 19th Jan 2017 02:52
played around with it for a while worked it out. Here's the code for anyone now or future needing it. will load an image make a memblock then read it and put it back onto screen.


+ Code Snippet
A child's dream never dies.





WickedX
8
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 19th Jan 2017 04:12
You could also read the color values from the memblock as dword values. Then if you need to break the color down to its red, green and blue components, you can use rgbr, rgbg and rgbb.

+ Code Snippet
smerf
12
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 19th Jan 2017 05:52
substituted the memblock in my program today didn't do much to boost speed. to many bitmap switching commands and get image commands I think. if I switch to straight memblocks will the write byte command overwrite a byte or bump a byte?
A child's dream never dies.





Derek Darkly
5
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 11th Feb 2017 15:03

Having any luck yet?
I'm trying to create meshes by inputting raw memblock data (something new for me)

This old tutorial has been useful:
https://forum.thegamecreators.com/thread/87105
Send your parents to noisy sprite demo hell... enter the D-Zone
smerf
12
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 12th Feb 2017 06:32 Edited at: 12th Feb 2017 06:45
yes I have the code in my post above works quite well Derek that's just for reading of corse. reading a mesh I suppose is basically the same just need to know what your looking for like header bytes that come before certain
data but that's beyond me don't deal with meshes much.

but your going in the right direction basically anything not within a 16x16chunk turn into a mesh and manually cull everything. and if ur using mesh data directly u could do simple lighting calculations on your cubes at the same time. Some say dbpo cant handle running a voxel but if done properly I think it could do it. ive have close to 200k separate objects on screen at a time and it was laggy of coarse but meshes are different .
A child's dream never dies.





Phaelax
DBPro Master
14
Years of Service
Recently Online
Joined: 16th Apr 2003
Location: Agartha
Posted: 25th Mar 2017 13:57
I know this post is a bit old, but I wrote a tutorial on image manipulation using memblocks. I wrote it probably at least 10 years ago or more (meaning I should probably rewrite a better one), but perhaps you'll find it useful.

http://www.zimnox.com/dbcc/darkbasic/tutorial_memblocks.pdf

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2017-04-24 16:07:45
Your offset time is: 2017-04-24 16:07:45