How i find the best way to convert AlphaColor Background qcolor to html value
HTML only having from 0.00 transparent to 1.00
and AlphaColor 1-255

and on html visible is from 0.7 to 1.0 !!
Have you a valid hack?



Qt Code:
  1. /* QGraphicsTextItem document() to div layer QFileInfo f destination file html
  2. to save external image if exist..
  3. */
  4. QString FloatDiagram::toDivHtml( QFileInfo f )
  5. {
  6. ///// #define POINT_TO_MM(mm) ((mm)/2.83465058) point px mm ?? ////
  7. #define ALPHAHTML(alpha) ((alpha)/254.99999999)
  8. QString masterpath = f.absolutePath()+"/"+FOPIMAGEDIR;
  9. /* Paint QGraphicsTextItem style to html css inline */
  10. QString styles = "position:absolute; top:"+QString("%1px")
  11. .arg(pos().y())+"; left:"+QString("%1px")
  12. .arg(pos().x())+"; width:"+QString("%1px")
  13. .arg(wi)+"; height:"+QString("%1px")
  14. .arg(hi)+"; ";
  15.  
  16. if (AlphaColor < 44) {
  17. styles.append(QString("background-color:transparent; ") );
  18. } else {
  19. styles.append(QString("background-color:%1; ").arg( BGColor.name() ) );
  20. }
  21. /* AlphaColor = backgroundqcolor.alpha(); */
  22. int alFaCol = qBound(0,AlphaColor,256);
  23. qreal percentos = ALPHAHTML( alFaCol );
  24. if (percentos < 1 && AlphaColor > 44) {
  25. QString Tnetto = QString("%1").arg(percentos, 0, 'f', 4);
  26. styles.append(QString("opacity:%1; filter: alpha(opacity=%1); -moz-opacity:%1; ").arg( Tnetto) );
  27. }
  28. /* insert border having? */
  29. if (BorderDicks > 0 ) {
  30. styles.append(QString("border:%2px solid %1; ").arg(MarginColor.name()).arg(BorderDicks));
  31. }
  32. /* IE !zindex qreal play as int zValue() */
  33. styles.append(QString("z-index:%1;").arg(QString("%1").arg(zValue()).replace(".","")));
  34.  
  35. QDomElement blox = doc.createElement("div");
  36. blox.setAttribute ("id",QString("layer_%1").arg(id));
  37. blox.setAttribute ("style",styles);
  38. doc.appendChild(blox);
  39.  
  40. QString errorStr;
  41. int errorLine, errorColumn;
  42. QDomDocument exdoc;
  43. if (!exdoc.setContent(document()->toHtml(),false, &errorStr, &errorLine, &errorColumn)) {
  44. return doc.toString(5);
  45. }
  46. QDomElement root = exdoc.documentElement();
  47. QDomNode child;
  48. QDomElement e = root.firstChildElement("body");
  49.  
  50. ImageFindertoHtml(e,masterpath); /* rewrite image href to new qfileinfo path image folder and write svg to png */
  51.  
  52.  
  53. /* import html to new QDomDocument to reformat later */
  54. child = e.firstChild();
  55. while ( !child.isNull() ) {
  56. if ( child.isElement() ) {
  57. blox.appendChild(doc.importNode(child,true).toElement());
  58. } else if (child.isText()) {
  59. blox.appendChild(doc.createTextNode(child.toText().data()));
  60. }
  61. child = child.nextSibling();
  62. }
  63.  
  64. return doc.toString(5);
  65. }
To copy to clipboard, switch view to plain text mode