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

Function bitmap_to_bitmap

src/laybasic/laybasic/layBitmapsToImage.cc:915–1054  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

913}
914
915void
916bitmap_to_bitmap (const lay::ViewOp &view_op, const lay::Bitmap &bitmap,
917 unsigned char *data,
918 unsigned int width, unsigned int height,
919 const lay::DitherPattern &dp,
920 const lay::LineStyles &ls,
921 double dpr)
922{
923 // quick exit, if line width is zero
924 if (view_op.width () == 0) {
925 return;
926 }
927
928 unsigned int nwords = (width + 31) / 32;
929 uint32_t *buffer = new uint32_t [nwords];
930
931 // determine endianess ..
932 unsigned int x = 0xc0000001;
933 unsigned char x0 = ((unsigned char *) &x) [0];
934
935 const DitherPatternInfo &dp_info = dp.pattern (view_op.dither_index ()).scaled (dpr);
936 const LineStyleInfo &ls_info = ls.style (view_op.line_style_index ()).scaled (view_op.width ());
937
938 for (unsigned int y = 0; y < height; ++y) {
939
940 unsigned int nbytes = ((width + 7) / 8);
941
942 if (view_op.width () > 1 || ! bitmap.is_scanline_empty (height - 1 - y)) {
943
944 const uint32_t *dither = dp_info.pattern () [(height - 1 - y + view_op.dither_offset ()) % dp_info.height ()];
945 unsigned int dither_stride = dp_info.pattern_stride ();
946
947 if (view_op.width () == 1) {
948
949 if (ls_info.width () > 0) {
950 render_scanline_std_edge (ls_info.pattern (), ls_info.pattern_stride (), &bitmap, height - 1 - y, width, height, buffer);
951 } else {
952 render_scanline_std (dither, dither_stride, &bitmap, height - 1 - y, width, height, buffer);
953 }
954
955 } else if (view_op.width () > 1) {
956
957 const lay::Bitmap *bp = &bitmap;
958
959 // Styled lines with width > 1 are not rendered directly, but through an intermediate step.
960 // We prepare the necessary precursor bitmaps now
961 lay::Bitmap precursor;
962 if (ls_info.width () > 0) {
963
964 precursor = lay::Bitmap (width, height, 1.0, 1.0);
965
966 LineStyleInfo lsi = ls_info;
967
968 for (unsigned int y = 0; y < height; y++) {
969 render_scanline_std_edge (lsi.pattern (), lsi.pattern_stride (), bp, y, width, height, precursor.scanline (y));
970 }
971
972 bp = &precursor;

Callers

nothing calls this directly

Calls 13

render_scanline_std_edgeFunction · 0.85
render_scanline_stdFunction · 0.85
render_scanline_pxFunction · 0.85
render_scanline_crossFunction · 0.85
styleMethod · 0.80
is_scanline_emptyMethod · 0.80
BitmapClass · 0.70
scanlineMethod · 0.60
widthMethod · 0.45
scaledMethod · 0.45
patternMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected