| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I am trying to make a view with a transparent ImageView bitmap that appears on top of a static color decoration. I have set the imageView as transparent, the actual bitmap file is transparent, and I am using this code to load the bitmap in the presenter: (Bitmap fromFile: 'chessProgram\graphics\whiteKnight.bmp') isTransparent: true. Everything already works fine except the transparency. I considered just having 2 images, one for a dark square and one for a light square (it's a chess program), but in that case the user would still be dragging the entire square with background color instead of just the piece. I have tried gdiplus image view as well. |
|
#2
| |||
| |||
| > I am trying to make a view with a transparent ImageView bitmap that > appears on top of a static color decoration. Try taking a look at GdiplusGraphics>>exampleGdipGAlphaBlending. I believe this shows what you want. You would probably need to create your own imageview and override #onPaintRequired: (or other method if, for example, you subclass DoubleBufferedView. Offhand I forget what that is). Hope this helps. -- Louis |
|
#3
| |||
| |||
| On Sep 4, 3:54*pm, Louis Sumberg <lsumb...@mindspring.com> wrote: > > I am trying to make a view with a transparent ImageView bitmap that > > appears on top of a static color decoration. > > Try taking a look at GdiplusGraphics>>exampleGdipGAlphaBlending. *I > believe this shows what you want. *You would probably need to create > your own imageview and override #onPaintRequired: (or other method if, > for example, you subclass DoubleBufferedView. *Offhand I forget what > that is). *Hope this helps. > > -- Louis Can anyone give me more clues on what to do here? I have tried over- riding onPaintRequired, but I'm kind of at a loss of what to do. I've tried a lot of different combinations of things. I don't have any clue how alpha transparency works in dolphin. Surely someone has had this issue before? |
|
#4
| |||
| |||
| Hihi, > Can anyone give me more clues on what to do here? I have tried over- > riding onPaintRequired, but I'm kind of at a loss of what to do. I've > tried a lot of different combinations of things. I don't have any > clue how alpha transparency works in dolphin. Surely someone has had > this issue before? I think I didn't really get your intention. Could you create a mockup picture of what you want to achieve and send it over? CU, Udo |
|
#5
| |||
| |||
| On Oct 1, 4:32*am, Udo Schneider <Udo.Schnei...@homeaddress.de> wrote: > Hihi, > > > * Can anyone give me more clues on what to do here? *I have tried over- > > riding onPaintRequired, but I'm kind of at a loss of what to do. *I've > > tried a lot of different combinations of things. *I don't have any > > clue how alpha transparency works in dolphin. *Surely someone has had > > this issue before? > > I think I didn't really get your intention. Could you create a mockup > picture of what you want to achieve and send it over? > > CU, > > Udo I want to create a chessboard with draggable pieces. The squares themselves are colored, decorated, etc. The piece graphics will have alpha transparency. If you drag the piece the transparent part of the image should work so that the user is not dragging a big square that covers up what is behind it. For a picture, pretty much any chess interface that I've ever seen like winboard, chessbase, java interfaces, etc. all have a piece graphic with transparency so you are not dragging a huge square but just the piece itself. Figuring out how drag and drop works is another issue, but I'll save any questions I have about that for later =) |
|
#6
| |||
| |||
| zenchess schrieb: > I want to create a chessboard with draggable pieces. The squares > themselves are colored, decorated, etc. The piece graphics will have > alpha transparency. If you drag the piece > the transparent part of the image should work so that the user is not > dragging a big square that covers up what is behind it. For a > picture, pretty much any chess interface that I've ever seen > like winboard, chessbase, java interfaces, etc. all have a piece > graphic with transparency so you are not dragging a huge square but > just the piece itself. > > Figuring out how drag and drop works is another issue, but I'll save > any questions I have about that for later =) If I understood you correctly you want each piece to be a independent view which is shown in front of the board view - although possible I would not recommend that route. Using this approach you are trying to convince Windows to use transparent/non-rectangular views for the pieces. Although possible it's very hard to get convincing and deterministic results using this way. Don't get me wrong: This is *not a Dolphin problem*! Windows is the limitation here! If you want to try anyway you should get familiar with the #isTransparent property (which is not as straightforward as it sounds - it just maps the Windows property) and the #onEraseRequired: event handler. You basically have to tell Windows to draw underlying controls (using #isTransparent) and on the top view you have to catch #onEraseRequired: to prevent windows from erasing the controls background with it's default background color. Another point that makes life hard here is the fact that there are subtle (but visible!) differences in the way childViews of the same parent are ordered. I can offer three "official" Windows ways which produce totally different results. IMHO Windows does not allow childViews of the same parent to overlap - or at least the result is not deterministic. So this was the long answer why I would not use the one view/piece approach. Why not simply to all the drawing on your own? GDI+ has no problems handling bitmaps with alpha transparency (e.g. PNGs). I hacked together a little example: http://udos.s3.amazonaws.com/USSimpleChess.zip Just download it and install "US SimpleChess" in your image. After fixing the path in ChessTileState>>tileImage you can evaluate "USChessBoardView show": Clicking into the squares moves the figure. Please note that the code /just works/. It's neither beautifull nor (I assume) bug free. However it might give you a hint on how to proceed. Hope this helps. CU, Udo |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.