2009-09-08 3 views
0

웹 페이지에 포함 할 PNG로 변환하려고 시도하는 일련의 Microsoft ISF (잉크 연속 서식) 이미지가 있습니다.Microsoft ISF에서 정확한 BoundingBox를 사용 하시겠습니까?

byte[] data; // data has the raw bytes of the ISF file 
Ink ink = new Ink(); 
Renderer renderer = new Renderer(); 
Stream outStream; // a Stream to hold the PNG data 
ink.Load(data); 
using (Strokes strokes = ink.Strokes) { 
    // get bounds of ISF 
    rect = strokes.GetBoundingBox(BoundingBoxMode.PointsOnly); 
    // create bitmap matching bounds 
    bm = new Bitmap(rect.Width, rect.Height); 
    // draw the ISF onto the Bitmap 
    using (Graphics g = Graphics.FromImage(bm)) { 
    g.Clear(Color.Transparent); 
    renderer.Draw(g, strokes); 
    } 
} 
// save the Bitmap to PNG format 
bm.Save(outStream, System.Drawing.Imaging.ImageFormat.Png); 

... 그러나, 이미지 크기가 비정상적으로 큰 것 같다 : 나는 성공적으로 비트 맵에 잉크를 그리고 PNG로 저장하는 C# 패키지 Microsoft.Ink을 사용했다. GetBoundingBox 메서드에 전달 된 BoundingBoxMode 열거 형을 변경하면 아무 것도 변경되지 않으며 465 픽셀 x 660 픽셀이고 실제 공간에서 25 자 x 30 픽셀을 차지하는 'a'필기체 만 포함하는 이미지를 얻게됩니다.

더 정확한 경계 상자를 가져 오는 방법에 대한 제안 사항이 있으십니까?

답변

0

경계 상자 사각형은 "잉크 공간"좌표에 있습니다. 즉, 비트 맵 및 그래픽 객체를 제거한 다음 renderer.InkSpacetoPixel을 사용하여 사각형을 변환합니다.

GetBoundingBox 통화와 비트 맵 BM의 창조 사이에이 라인을 추가하고 비트 맵이 제대로 크기해야합니다

Bitmap bmTrash = new Bitmap(10, 10); 
Graphics gTrash = Graphics.FromImage(bmTrash); 
renderer.InkSpaceToPixel(gTrash, rect.Location); 
renderer.InkSpaceToPixel(gTrash, rect.Size); 
관련 문제