|
-
Jan 5th, 2022, 05:33 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Cairo Equivalents Setpixel(Yes & Easy), Getpixel(???) [L-Plate Learner Edition]
Hi all, another question for the Cairo squad. Looks like Pycairo has a pixel interrogation thing, but we don’t appear to?
My question is basically, for speed (like running it hundreds of times a turn). Right now I use a couple of ways of analysing a pixel map image of a 1000x1000px.
1. Picturebox, Getpixel. (Somewhat slow)
2. Matrix, just accessing the entry. (Quite fast)
3. Cairo??

For those interested, I copy a PNG picture (an icon value map) to an invisible form.picturebox of 1000x1000 pixels. I interrogate those close-by pixel values to give icon numbers (of the cairo-imagelist) of the local map. It’s about-ish 20x20 pixels in total per go. This works pretty well, as the map only changes when you swap screens. (If that doesn’t make sense, imagine the picturebox has a shrunken down map on it made only of numbers).
Terrain maps, tree maps, grass and object maps are pretty good with this method. It can have many, many map chunks, as those 1000 square PNG’s are saved in files. Cairo allows saving and editing, meaning the map is living and can be literally 10’s to 100’s of kilometres long.
However, the big problem is with monsters and characters. A lot of them can fit on a 1000 square map chunk. Initially, I use a proximity matrix to count who is close and who isn’t. Then render that proximity matrix. It’s fast.
Now, here’s the trick. I’d like to, if possible, to stop using pictureboxes and matrices altogether, and only use surfaces as they are becoming my ‘normal way to think’.
It’s easy to ‘setpixel x,y’ of a (Long value) colour on a Cairo surface, with the rectangle function. But, can we ‘getpixel x,y’ of a (Long value) colour from that surface?
Pycario reference: https://stackoverflow.com/questions/...o-imagesurface
I had a look of the VB6 functions attached to the surface context, but nothing was apparent.
And aside, to the person who PM’d me to stop using images in my posts!

https://www.youtube.com/watch?v=2HJx...annel=RoyalOss
To everyone else, thank you kindly for all your help. 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|