public CanonBitmap readBitmap(CanonHeader header, int width, int height) { CanonBitmap bmp; if (width <= 0 || height <= 0) { throw new BitmapSizeException("width and height must be > 0"); } int size = width * height; int padding = (size + CanonHeader.SIZE) % (byte)_byteAlign == 0 ? 0 : (byte)_byteAlign - (size + CanonBitmapHeader.SIZE) % (byte)_byteAlign; //Console.WriteLine("trying to read {0} bytes, {0}%{1}={2} -> padding {3} bytes (pad_to {4})", // size, CanonBitmapHeader.SIZE, (size + CanonBitmapHeader.SIZE) % (byte)_byteAlign, padding, _byteAlign); byte[] data = new byte[size + padding]; if (_dataFile.Read(data, 0, size + padding) != (size + padding)) { throw new EndOfStreamException("cannot read the whole bitmap data (EOF?)"); } bmp = new CanonBitmap(header, data); bmp.Width = width; bmp.Height = height; return(bmp); }
private void AddImageToPanel(CanonBitmap i) { Control c = CreatePanelImage(i); flpBitmaps.Controls.Add(c); flpBitmaps.ScrollControlIntoView(c); }
private void ShowBitmap(CanonBitmap i) { if (i != null) { pbZoomed.Image = pbMediumZoom.Image = pbOriginal.Image = i.Pic; } }
private Control CreatePanelImage(CanonBitmap i) { int border = 4; PictureBoxEx pb = new PictureBoxEx(); pb.Width = pb.Height = CanonBitmapProvider.DEFAULT_HEIGHT + border; if (i != null) { //if(i.Header.Unknown > pb.Width) if (i.Header is CanonBitmapHeader) { pb.Width = i.Header.Value2 + border; } else if (i.Header is CanonBigBitmapHeader) { pb.Width = i.Header.Value1 + border; pb.Height = i.Header.Value2 + border; } pb.SizeMode = PictureBoxSizeMode.CenterImage; CreateTooltip(pb, i); try { if (i.Header is CanonBitmapHeader) { pb.Image = CanonBitmap.FixedSize(i.Pic, i.Header.Value2, i.Height); } else { pb.Image = i.Pic; } } catch { } } return(pb); }
private void GenerateBitmap(long pos) { lblStatus.Text = ""; _currentImage = GetBitmap(pos); }
private void CreateTooltip(Control c, CanonBitmap i) { toolTip1.SetToolTip(c, String.Format("0x{0:X8} w: {1} ws: {2}", i.Header.Origin, i.Header.Value1, i.Header.Value2)); }