protected virtual void InitLibrary(JB2Dictionary jim) { int nshape = jim.InheritedShapes; shape2lib_Renamed_Field.Clear(); Lib2Shape.Clear(); _libinfo.Clear(); for (int i = 0; i < nshape; i++) { int x = i; shape2lib_Renamed_Field.Add(x); Lib2Shape.Add(x); JB2Shape jshp = jim.GetShape(i); //final Rectangle r = new Rectangle(); //libinfo.addElement(r); //jshp.getGBitmap().compute_bounding_box(r); _libinfo.Add(jshp.Bitmap.ComputeBoundingBox()); } }
protected virtual int CodeRecordA(int rectype, JB2Dictionary jim, JB2Shape xjshp) { Bitmap bm = null; int shapeno = -1; rectype = CodeRecordType(rectype); JB2Shape jshp = xjshp; switch (rectype) { case NewMarkLibraryOnly: case MatchedRefineLibraryOnly: { if (!_encoding) { jshp = new JB2Shape().Init(-1); } else if (jshp == null) { jshp = new JB2Shape(); } bm = jshp.Bitmap; break; } } switch (rectype) { case StartOfData: { CodeImageSize(jim); CodeEventualLosslessRefinement(); if (!_encoding) { InitLibrary(jim); } break; } case NewMarkLibraryOnly: { CodeAbsoluteMarkSize(bm, 4); CodeBitmapDirectly(bm); break; } case MatchedRefineLibraryOnly: { int match = CodeMatchIndex(jshp.Parent, jim); if (!_encoding) { jshp.Parent = Convert.ToInt32((Lib2Shape[match])); } Bitmap cbm = jim.GetShape(jshp.Parent).Bitmap; Rectangle lmatch = (Rectangle)_libinfo[match]; CodeRelativeMarkSize(bm, (1 + lmatch.Left) - lmatch.Right, (1 + lmatch.Top) - lmatch.Bottom, 4); CodeBitmapByCrossCoding(bm, cbm, jshp.Parent); break; } case PreservedComment: { jim.Comment = CodeComment(jim.Comment); break; } case RequiredDictOrReset: { if (!GotStartRecordP) { CodeInheritedShapeCount(jim); } else { ResetNumcoder(); } break; } case EndOfData: break; default: throw new ArgumentException("Image bad type"); } if (!_encoding) { switch (rectype) { case NewMarkLibraryOnly: case MatchedRefineLibraryOnly: { if (xjshp != null) { jshp = jshp.Duplicate(); } shapeno = jim.AddShape(jshp); AddLibrary(shapeno, jshp); break; } } } return(rectype); }