How can I get what color has specific point inside BView ?
I want something like this
rgb_color GetPixel(int x, int y);
How can I get what color has specific point inside BView ?
I want something like this
rgb_color GetPixel(int x, int y);
Hi!
Never tried this kind of thing myself, but from the BeBook’s BView description, I suspect you first do a “MovePenTo(BPoint point);
” and then a “rgb_color HighColor();
” or “rgb_color LowColor()
”.
Regards,
Humdinger
…or not. Sorry, that Low/HighColor() apparently gets the BVIews general colour.
Edited:
Bits() gives you access to your bitmap’s data (if you’re talking about the colour of a pixel of a bitmap).
See the Colors! source for inspiration.
Regards,
Humdinger
I just got similar idea. 1st to create 1pixel destination bitmap with 32bit color. 2nd copy single pixel from given source BView location into it. 3rd access this pixel in destination bitmap using Bits().
You can’t really do this from the API, because your view may not even be working with pixels at all. It could be printing to paper, or sending command through the network to the remote_app_server.
In general, there is no guarantee that your BView drawings are stored or even drawn at all. Your view may be (partially) obscured by another window on screen, and the point you are trying to get the color from may not be drawn at all.
The only way would be to attach your view to a BBitmap and render there. Then you can use Bits() to peek at the rendered bitmap image. You can use a single-pixel bitmap with an appropriate transform to achieve this.
Ok, thanks. I’m bothering with porting of wxWidgets.
Maybe some old ports can give you some ideas / help
Is possible to draw transparent pixel into target bitmap ?
Just excerpt from code
view.SetDrawingMode(B_OP_ERASE);
view.SetLowColor(B_TRANSPARENT_COLOR);
view.DrawBitmap(srcMask);
Trying to apply mask of transparent area.
The color transferred isn’t transparent. The ALPHA component is transferred as 0xFF and not as 0x00 (as stated in B_TRANSPARENT_COLOR)
Hi did you initalized the Bitmap with B_RGB32 ?
Only B_RGB32 and B_RGBA15 support alpha mask.
https://www.haiku-os.org/legacy-docs/bebook/BBitmap.html
[Edit]
Maybe the documentation for SetBlendingMode() can help you further.
https://www.haiku-os.org/legacy-docs/bebook/BView.html#BView_Hook
I’m using B_RGBA32 for mask bitmap and if transferring mask to the screen transparency is visible (just for testing to make sure mask is ok). Then creating a new bitmap also B_RGBA32 for masked image. The source image is B_RGB24.
With B_OP_COPY is copied into masked image and then applying steps of code above. Transparent pixel components are copied except ALPHA which is set always to 0xFF and this is the reason why it is not working. All this is done off-screen using BView and then masked image is painted with DrawBitmap. Pixels where I expect to have transparent color 0x00777477 in result are 0xFF777477 instead. I thought that I’m able to set transparent pixels using B_OP_ERASE but now seem I’m wrong. I’m not sure if can use SetBlendingMode() it requires B_OP_ALPHA and my image is B_RGB24. To use it need to merge first with mask into R_RBGA32.
Tested B_RGB32 in place of B_RGBA32 but the result was same.
I i see what you want to achive.
Ok from what i know (and thats sadly only a little)
The Alphamask in Bitmaps only defines how translucent
the Pixel is. So it only defines how much the
Pixel benath will shine through. It doesent work
like the gimp version of a alpha Mask, wich is not
as it works for BBitmaps
You can see a diskussion about this here:
https://www.haiku-os.org/node/5546
What you maybe want to achive (cliping a Bitmap??)
could maybe done with
ClipToPicture()…
https://www.haiku-os.org/legacy-docs/bebook/BView.html
but since it only accepts a BPicture
this could be quite difficult… depending on your taks.
The best person to talk to would be pulkomandy or stippi
(you can only reach stippi over malinglist)
Hi,
You should be able to fill the alpha channel just like the RGB channels, using B_OP_COPY or B_OP_OVER on a B_RGBA32 bitmap. This means no blending or other operations are done in these modes.
The "brainstorming notes" Paradoxon linked to have since been implemented, so ClipToPicture can be used to restrict the drawing, complete with proper alpha masks and complex blending. Since a picture can store all drawing operations on a view (including drawing a bitmap), you can also use it to implement masking with a bitmap (but there may be strange results if you use transforms at the same time).
Wow thats awesome!!!
That’s Very Impressove! Did you get Codeblocks working by porting the code directly, or did you port WxWidgets over to haiku? If so for either, is there a way we can see the work in progress source code for either?
Of course wxWidgets-2.8.12 but this is just partial port. Only components required by Code::Blocks. The work is still not complete. There are lot of situations where it crashes or can crash. When the work will be done I want make the release publicly available over HaikuDepot for free. Source can be emitted also after collecting requested amount of money for time spent with porting. How to collect them I don’t know. Perhaps can I obtain some amount from haiku fund.