MCPcopy Create free account
hub / github.com/KLayout/klayout / bitmaps_to_image

Function bitmaps_to_image

src/laybasic/laybasic/layBitmapsToImage.cc:468–707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466}
467
468void
469bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
470 const std::vector<lay::Bitmap *> &pbitmaps_in,
471 const lay::DitherPattern &dp,
472 const lay::LineStyles &ls,
473 double dpr,
474 tl::PixelBuffer *pimage, unsigned int width, unsigned int height,
475 bool use_bitmap_index,
476 tl::Mutex *mutex)
477{
478 bool transparent = pimage->transparent ();
479
480 std::vector<unsigned int> bm_map;
481 std::vector<unsigned int> vo_map;
482
483 vo_map.reserve (view_ops_in.size ());
484 bm_map.reserve (view_ops_in.size ());
485 unsigned int n_in = 0;
486
487 // drop invisible and empty bitmaps, build bitmap mask
488 for (unsigned int i = 0; i < view_ops_in.size (); ++i) {
489
490 const lay::ViewOp &vop = view_ops_in [i];
491
492 unsigned int bi = (use_bitmap_index && vop.bitmap_index () >= 0) ? (unsigned int) vop.bitmap_index () : i;
493 const lay::Bitmap *pb = bi < pbitmaps_in.size () ? pbitmaps_in [bi] : 0;
494
495 if ((vop.ormask () | ~vop.andmask ()) != 0 && pb && ! pb->empty ()) {
496 vo_map.push_back (i);
497 bm_map.push_back (bi);
498 ++n_in;
499 }
500
501 }
502
503 // Styled lines with width > 1 are not rendered directly, but through an intermediate step.
504 // We prepare the necessary precursor bitmaps now
505 std::map<unsigned int, lay::Bitmap> precursors;
506 create_precursor_bitmaps (view_ops_in, vo_map, pbitmaps_in, bm_map, ls, width, height, precursors, mutex);
507
508 std::vector<lay::ViewOp> view_ops;
509 std::vector<const lay::Bitmap *> pbitmaps;
510 std::vector<std::pair <tl::color_t, tl::color_t> > masks;
511 std::vector<uint32_t> non_empty_sls;
512
513 view_ops.reserve (n_in);
514 pbitmaps.reserve (n_in);
515 masks.reserve (n_in);
516 non_empty_sls.reserve (n_in);
517
518 // to optimize the bitmap generation, the bitmaps are checked
519 // for emptyness in slices of "slice" scanlines
520 unsigned int slice = 32;
521
522 // allocate a pixel buffer large enough to hold a scanline for all
523 // planes.
524 unsigned int nwords = (width + 31) / 32;
525 uint32_t *buffer = new uint32_t [n_in * nwords];

Callers 6

single_bitmap_to_imageFunction · 0.85
to_imageMethod · 0.85
to_image_monoMethod · 0.85
paint_eventMethod · 0.85
transfer_to_imageMethod · 0.85

Calls 15

create_precursor_bitmapsFunction · 0.85
render_scanline_std_edgeFunction · 0.85
render_scanline_stdFunction · 0.85
render_scanline_pxFunction · 0.85
render_scanline_crossFunction · 0.85
transparentMethod · 0.80
styleMethod · 0.80
first_scanlineMethod · 0.80
last_scanlineMethod · 0.80
is_scanline_emptyMethod · 0.80
scan_lineMethod · 0.80
reserveMethod · 0.45

Tested by

no test coverage detected