Merge & Position any no. of Images

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Merge & Position any no. of Images

Post by RASHAD »

Thanks KCC
Previous Posts updated
Egypt my love
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Merge & Position any no. of Images

Post by Lord »

Hi!
davido wrote:...
2a. The pictures can be lost in all four directions.
...
Maybe a #PB_Canvas_ClipMouse is helpfull?

Edit:
I almost forgot:
#PB_Canvas_Keyboard has also to be added in order get mousewheel working.
At least here.
Image
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Merge & Position any no. of Images

Post by ChrisR »

Hi Rashad,
For the Added transparency effect as per infratec suggestion
You forgot to change the 2 lines that Bernd was referring to

Code: Select all

;DrawImage(ImageID(Images()\img),Images()\x,Images()\y) ==>
DrawAlphaImage(ImageID(Images()\img),Images()\x,Images()\y,Images()\alphatest) ; draw all images with z-order
 
;Procedure AddImage(x,y,img,alphatest=0) ==>
Procedure AddImage(x,y,img,alphatest=255)
I feel like a small newbie next to all of you and I have a lot to learn from all of you.
Thanks for sharing, it's very nice
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Merge & Position any no. of Images

Post by RASHAD »

Thanks ChrisR
Sorry,I am doing these changes blindly after you and infratec
I spent a lot of time to get any images that can show me that effect
But without any success
Just added the changes and the necessary code to keep everything intact
Still doing the changes blindly after both of you :)
So you are in trouble if it did not work
Egypt my love
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Merge & Position any no. of Images

Post by ChrisR »

To get your good eyes back, I think you're playing with images that have their own transparency.
The addition here is to apply a transparency on an opaque image as below
ex with: #PB_Compiler_Home + "Examples\Sources\Data\Geebee2.bmp"

Image

RASHAD wrote:As I expected there is a problem with Procedure Bring2Top(index)
A little my fault with If ListSize(Images()) > 0 added
It seems better with If isCurrentItem

davido wrote:@RASHAD,
Could you introduce code to prevent images being moved out of bounds?
On my side I use the GridMatch procedure for that, if it can help

Code: Select all

Procedure.i GridMatch(Value.i, Min.i=0, Max.i=4096)
  If Value < Min
    ProcedureReturn Min
  ElseIf Value > Max
    ProcedureReturn Max
  Else
    ProcedureReturn Value
  EndIf
EndProcedure

;Todo also for Case 6,7,8,9 (eg case 9: If Images()\y < GadgetHeight(0)-10 : Images()\y + 1 : DrawCanvas() : EndIf)

Case #PB_EventType_MouseMove
...
;Images()\x = x - currentItemXOffset ==>
Images()\x = GridMatch(x - currentItemXOffset, 0, GadgetWidth(0)-10)
;Images()\y = y - currentItemYOffset ==>
Images()\y = GridMatch(y - currentItemYOffset, 0, GadgetHeight(0)-10)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Merge & Position any no. of Images

Post by RASHAD »

Hi ChrisR
Problem solved
I added preventing moving any image to left and top (Logic) to the 2 examples using native commands allready
I do not think that preventing moving right and bottom is a good idea while it is so easy to do it as I did for left & top
BTW :
No need for your Procedure it will be no good with grab the image by Mouse.
Thanks
Egypt my love
Post Reply