Exemplo n.º 1
0
        private ClutDefinitionSegment GetClutDefinitionSegment(ObjectDataSegment ods)
        {
            foreach (var rcs in RegionCompositions)
            {
                foreach (var o in rcs.Objects)
                {
                    if (o.ObjectId == ods.ObjectId)
                    {
                        foreach (var cds in ClutDefinitions)
                        {
                            if (cds.ClutId == rcs.RegionClutId)
                            {
                                return(cds);
                            }
                        }
                    }
                }
            }

            if (ClutDefinitions.Count > 0)
            {
                return(ClutDefinitions[0]);
            }

            return(null); // TODO: Return default clut
        }
Exemplo n.º 2
0
        public Point GetImagePosition(ObjectDataSegment ods)
        {
            if (SubtitleSegments == null)
            {
                ParseSegments();
            }

            var p = new Point(0, 0);

            foreach (var rcs in RegionCompositions)
            {
                foreach (var o in rcs.Objects)
                {
                    if (o.ObjectId == ods.ObjectId)
                    {
                        foreach (var cds in PageCompositions)
                        {
                            foreach (var r in cds.Regions)
                            {
                                if (r.RegionId == rcs.RegionId)
                                {
                                    p.X = r.RegionHorizontalAddress + o.ObjectHorizontalPosition;
                                    p.Y = r.RegionVerticalAddress + o.ObjectVerticalPosition;
                                    return(p);
                                }
                            }
                        }
                        p.X = o.ObjectHorizontalPosition;
                        p.Y = o.ObjectVerticalPosition;
                    }
                }
            }

            return(p);
        }
        public Bitmap GetImage(ObjectDataSegment ods, bool AddBorder = false)
        {
            if (SubtitleSegments == null)
            {
                ParseSegments();
            }

            // this caches the image, removing so border switching works, do I need to clean up memory?
            if (ods.Image != null)
            {
                //return ods.Image;
                ods.Image.Dispose();
            }

            var cds = GetClutDefinitionSegment(ods);

            ods.DecodeImage(_dataBuffer, ods.BufferIndex, cds);

            if (AddBorder)
            {
                return(AddBitmapBorder(ods.Image, Color.White));
            }
            else
            {
                return(ods.Image);
            }
        }
Exemplo n.º 4
0
        public Bitmap GetImage(ObjectDataSegment ods)
        {
            if (SubtitleSegments == null)
            {
                ParseSegments();
            }

            if (ods.Image != null)
            {
                return(ods.Image);
            }

            var cds = GetClutDefinitionSegment(ods);

            ods.DecodeImage(_dataBuffer, ods.BufferIndex, cds);
            return(ods.Image);
        }