Hi,
First off, thanks for pngwriter - it has so far been a very handy tool. I am
however having a problem with plot-blending in my application.
The aim is to create a blended png which is the result of overlaying several
png's on top. I am able to create the overlays ok but as soon as I blend,
only the first overlay is processed correctly.
I suspect that this is because in my implementation, the first overlay is
processed using a new
pngwriter instance (with a black background) whereas subsequent overlays are
processed using a pngwriter that was created using readfromfile(...).
>From debugging I see that the correct channel value is read out of the overlay
>and the values
for opacity etc are correct. However, the resulting "blended" png remains the
original semi-opaque version
of the first overlay to be processed.
If I set opacity to 1.0, the new values are still not set into the base png.
Similarly, the pngs to be
blended have both a depth of 16 and no transparency (they are only generated by
pngwriter anyway).
Can you offer any advice or see what I have missed? More info is in the
comments below...
Many thanks,
+++++++++ CODE ++++++++++++
// NOTE: destinationDir is set in the constructor of the TopologyVisulaiser
// wrapper for pngwriter
int TopologyVisualiser::overlayTopology(string overlay, string base,
int colour, int w,
int h,
double opacity){
// read the base file i.e. the blend result
pngwriter* baseWriter;
// the following simply creates a new base png writer if it
// doesn't yet exist or reads in the current blended version
string baseFilename = destinationDir + "/" + base + ".png";
ifstream baseFile(baseFilename.c_str());
if (baseFile) {
baseWriter = new pngwriter();
baseWriter->readfromfile(baseFilename.c_str());
} else {
baseWriter = new pngwriter(w, h, 0, baseFilename.c_str());
}
baseFile.close();
// the following simply creates a new overlay png writer if the
// specified overlay doesn't yet exist (doesn't happen)
// or reads in the current blended version
pngwriter* overlayWriter;
string overlayFilename = destinationDir + "/" + overlay + ".png";
ifstream overlayFile(overlayFilename.c_str());
if (overlayFile) {
overlayWriter = new pngwriter();
overlayWriter->readfromfile(overlayFilename.c_str());
} else {
overlayWriter = new pngwriter(w, h, 0, overlayFilename.c_str());
}
overlayFile.close();
int numBaseRows = baseWriter->getheight();
int numOverlayRows = overlayWriter->getheight();
int numBaseCols = baseWriter->getwidth();
int numOverlayCols = overlayWriter->getwidth();
double overlayValue = 0.0;
for (int y = 1; y <= numOverlayRows && y <= numBaseRows; y++){
for (int x=1; x <= numOverlayCols && x <= numBaseCols; x++) {
//overlays are in green depending on the colour
argument (1,2,3),
// the value of the overlay is blended into that
channel. This is because
// all overlays use only the green channel whereas the
blended png may
// be recorded to the red, green or blue channels
overlayValue = overlayWriter->dread (x,y,2);
switch (colour) {
case 1:
baseWriter->plot_blend(x,y,opacity,
overlayValue, 0.0, 0.0);
break;
case 2:
baseWriter->plot_blend(x,y,opacity,
0.0, overlayValue, 0.0);
break;
case 3:
baseWriter->plot_blend(x,y,opacity,
0.0, 0.0, overlayValue);
break;
}
}
}
baseWriter->close();
overlayWriter->close();
return 0;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
http://pngwriter.sourceforge.net/
PNGwriter-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pngwriter-users