Multipass and DrawBitmap() [SOLVED]
-
On 24/01/2017 at 06:14, xxxxxxxx wrote:
Hi WickedP, thanks for writing us.
With reference to your request, i confirm that passing a MultipassBitmap object as first parameter of the DrawBitmap() method is not recommended although MultipassBitmap class inherits from BaseBitmap.
It's instead preferable, with a straightforward solution, to feed the DrawBitmap with a temp BaseBitmap object whose buffer has been previously filled with the data taken from the desired layer of the MultipassBitmap object.... ... void TestUserArea::DrawMsg(Int32 x1, Int32 y1, Int32 x2, Int32 y2, const BaseContainer& msg) { OffScreenOn(); SetClippingRegion(x1, y1, x2, y2); // check the existence of the MultipassBitmap object if (_mpbmp) { // choice one of the layer of the MultipassBitmap object const Int32 i = 3; // check the value it's within the allowed range DebugAssert(i < _mpbmp->GetLayerCount()); // get the pointer to the desired layer MultipassBitmap* layer = _mpbmp->GetLayerNum(i); // check the existence of the layer if (!layer) return; const Int32 layerW = layer->GetBw(); const Int32 layerH = layer->GetBh(); // autoalloc a temp BaseBitmap object AutoAlloc<BaseBitmap> tmpBmp; if (!tmpBmp) return; // copy the layer buffer data to the tmp buffer layer->CopyPartTo(tmpBmp, 0, 0, layerW, layerH); // just display the tmp BaseBitmap DrawBitmap(tmpBmp, x1, y1, x2-x1, y2-y1, 0, 0, layerW, layerH, BMP_NORMAL); } } ... ...
Best, Riccardo
-
On 25/01/2017 at 03:18, xxxxxxxx wrote:
Thanks Riccardo,
that seems to have sorted that out. Just a note for anyone else, the plain CopyTo() won't work, users need to use CopyPartTo().
I have two follow queries if that's OK Riccardo (or anyone else!) :
1. The flag BMP_INSERTLAST always returns a null result when using AddLayer() on the multipassbitmap. What can cause a null return here?
2. Setting the MPBTYPE_SHOW flag to true with SetParameter() isn't showing the layers in the picture viewer. I don't need the PV for the plugin, but I'm wanting to use it for display purposes while I test to see that everything is doing as it should (outside of my display). How can I get layers displayed correctly in the PV with ShowBitmap()?
WP.
-
On 20/02/2017 at 23:26, xxxxxxxx wrote:
I believe I have answered the second one. You appear to have to set the MPBTYPE_SAVE flag to true as well.
The first one is still giving me issues with null returns.
WP.
-
On 08/03/2017 at 01:26, xxxxxxxx wrote:
Hi WickedP,
I confirm - apologizing for coming so lately - that you've hit a bug which has now been reported and going to be fixed.
Best, Riccardo.
-
On 20/03/2017 at 03:26, xxxxxxxx wrote:
Hi knickknack,
no troubles, I'm still battling a component of this.
I'm trying to get a layered MultipassBitmap to display in my user area with the layering effect. Here are the steps I follow:
1. draw into a GeClipMap - then copy to layer one
2. draw into another GeClipMap - then copy into layer two
(in both the above steps, the alpha channel is copied manually)
3. Copy MP to a normal Bitmap
4. display in user area.The problem I get is there's no layering effect happening. Do MultipassBitmap layers come with their own alpha channel? Or do we have to add this ourselves? How can we see the alphas in the picture viewer?
When I send one of the GeClipMaps to the picture viewer via a BaseBitmap, it doesn't seem to show the alpha channel. I copy the CM into a normal bitmap, and manually create and edit the alpha channel of the bitmap. But when I display this in the picture viewer, there's no alpha channel anywhere?
WP.
-
On 22/03/2017 at 01:51, xxxxxxxx wrote:
Hi WickedP, thanks for writing us.
With reference to your last post, I think that the relevant point is what and how you copy from MultipassBitmap to BaseBitmap in order to have it shown in your user area. Note that MultipassBitmap object doesn't come with any merge or layering effect on their own and they should be considered a sort of stack of bitmaps organised in folders. Merging the different layers (like using an "Add" or "Difference" or "Hue" or "Multiply" mode) it's something up to be implemented on your side as actually happens in PV.
With reference to the Alpha channel when allocating a new MultipassBitmap object the first default layer is created as RGBA providing you with a default alpha channel. That said you can add alpha layers as much as image layers by using the proper method and this depends on your needs if multiples alpha are required (usually a single alpha is sufficient but you can try to add a Depth channel in the Multipass section of the render settings to add another "alpha" channel representing depth).
Last but not least, in picture viewer you're aware of the alpha channel existence by looking at the "Layers" tab: if the alpha has been generated you should see an alpha layer and to perform alpha filtering it's just needed to switch on the alpha by clicking on the black-circle square-surrounded icon on the upper left of the channel.Best, Riccardo
-
On 22/03/2017 at 03:55, xxxxxxxx wrote:
Hi knickknack,
thanks for your response. Just to clarify a couple of things:
Originally posted by xxxxxxxx
Merging the different layers (like using an "Add" or "Difference" or "Hue" or "Multiply" mode) it's something up to be implemented on your side as actually happens in PV.
Does this mean I should loop over the layers and do my own "layering" when drawing into the final bitmap? I.e. a pixel-by-pixel test of each layer, it's colour and alpha values etc?
Originally posted by xxxxxxxx
That said you can add alpha layers as much as image layers by using the proper method and this depends on your needs if multiples alpha are required (usually a single alpha is sufficient but you can try to add a Depth channel in the Multipass section of the render settings to add another "alpha" channel representing depth).
This one's a little confusing. When I render a document to the PV I get two layers; one with the picture, and a second layer which is the black and white alpha. But when I add an alpha to my multipassbitmaps, it looks like I end up with 2 further alphas(?) on each layer itself. See this screen shot. What's the difference between the two?
WP.
-
On 04/04/2017 at 09:22, xxxxxxxx wrote:
Hi WickedP with reference to the first question I confirm that you have to do your own layering when drawing in the final bitmap.
With reference to the second point, there's a relevant different the pictures attached: on the left (the one pointed as 'render to PV') shows a multipass bitmap with two layers: the first named as "Background", the second name "Alpha". On the right side instead you have a multipass bitmap with three layers each of which comes with its own two alpha channels.
Whilst alpha "channels" are added to a specific layer in a MultipassBitmap by using the MultipassBitmap::AddAlpha() invoked from the layer instance, adding an alpha layer to root of the MultipassBitmap requires the AddAlpha() to be invoked from the root instance as shown in the example below (picture)... MultipassBitmap* res = MultipassBitmap::Alloc(width, height, mode); if (!res) return nullptr; // add a alpha layer to the root of the Multipass bitmap MultipassBitmap* alphaLayer = res->AddAlpha(nullptr, COLORMODE_GRAY); alphaLayer->SetParameter(MPBTYPE_NAME, "alpha"); alphaLayer->SetParameter(MPBTYPE_SAVE, true); alphaLayer->SetParameter(MPBTYPE_SHOW, true); // get the first layer which is automatically created at the res allocation time and fill it MultipassBitmap* layer = res->GetLayerNum(0); if (!layer) return res; layer->SetParameter(MPBTYPE_NAME, "checker_R-Y"); layer->SetParameter(MPBTYPE_SAVE, true); layer->SetParameter(MPBTYPE_SHOW, true); // fill the first layer with red/yellow checkerboard // FillRGBChannel is a dummy custom-made function to fill a bitmap with a checkboard pattern if (!FillRGBChannel((BaseBitmap* )layer, 8, 8, Vector(255, 0, 0), Vector(255, 255, 0))) { MultipassBitmap::Free(res); return nullptr; } // add an alpha channels to the first layer alphaLayer = layer->AddAlpha(nullptr, COLORMODE_GRAY); alphaLayer->SetParameter(MPBTYPE_SAVE, true); alphaLayer->SetParameter(MPBTYPE_SHOW, true); alphaLayer->SetParameter(MPBTYPE_NAME, "alpha_8x8"); // fill the added alpha layer with checkerboard mask // FillAlphaChannel is a dummy custom-made function to fill a bitmap with a checkboard mask pattern if (!FillAlphaChannel(layer, 0, 32, 32, 255, 0, false)) { MultipassBitmap::Free(res); return nullptr; } ...
Best, Riccardo
-
On 08/04/2017 at 20:53, xxxxxxxx wrote:
Thanks knickknack,
I think this covers everything I'm needing to know.
Cheers,
WP.
-
On 09/04/2017 at 10:09, xxxxxxxx wrote:
Hi,
Are FillRGBChannel() and FillAlphaChannel() custom hand made functions?
I can't find them in the SDK.-ScottA
-
On 10/04/2017 at 01:18, xxxxxxxx wrote:
Yes Scott, they are both custom functions made for the purpose of filling the bitmaps with something.
Best, Riccardo