Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002587 [JEDI VCL] 00 JVCL Components minor always 2005-02-02 08:11 2005-03-01 13:34
Reporter CCR View Status public  
Assigned To remkobonte
Priority normal Resolution fixed  
Status resolved   Product Version
Summary 0002587: Replace TJvCustomRichEdit.InsertBitmap with TJvCustomRichEdit.InsertGraphic, like this...
Description With TImageDataObject do this:
1) Remove GetExtent, as it's a bit pointless.
2) Replace FBitmap: TBitmap with FGraphic: TGraphic,
   and alter the constructor to fit.
3) Rewrite GetData to be the following:

function TImageDataObject.GetData(const FormatEtcIn: TFormatEtc;
  out Medium: TStgMedium): HRESULT;
  SizeMetric: TPoint;
  Buffer: Pointer;
  Length: UINT;
  DC: HDC;
  hMem: THandle;
  pMFP: PMetafilePict;
  // Handle only MetaFile
  if (FormatEtcIn.tymed and TYMED_MFPICT) = 0 then
    Result := DV_E_FORMATETC;
  if FGraphic is TMetafile then //Get a Win3x-style HMETAFILE handle
    with TMetafile(FGraphic) do //from a HENHMETAFILE one.
      SizeMetric.X := MMWidth;
      SizeMetric.Y := MMHeight;
      Buffer := nil;
      Length := 0;
      DC := GetDC(0);
        Length := GetWinMetaFileBits(Handle, 0, nil, MM_ANISOTROPIC, DC);
        GetMem(Buffer, Length);
        if GetWinMetaFileBits(Handle, Length, Buffer,
             MM_ANISOTROPIC, DC) = Length then
          hMF := SetMetaFileBitsEx(Length, Buffer)
          hMF := 0;
        if Buffer <> nil then FreeMem(Buffer, Length);
        ReleaseDC(0, DC);
    SizeMetric.X := MulDiv(FGraphic.Width,
      CHundredthMMPerInch, Screen.PixelsPerInch);
    SizeMetric.Y := MulDiv(FGraphic.Height,
      CHundredthMMPerInch, Screen.PixelsPerInch);
    // Create Metafile DC and set it up
    DC := CreateMetafile(nil);
    SetWindowOrgEx(DC, 0, 0, nil);
    SetWindowExtEx(DC, SizeMetric.X, SizeMetric.Y, nil);

    if FGraphic.ClassType = TIcon then
      DrawIconEx(DC, 0, 0, TIcon(FGraphic).Handle, SizeMetric.X, SizeMetric.Y,
        0, 0, DI_NORMAL)
      with TCanvas.Create do
        Handle := DC;
        StretchDraw(Rect(0, 0, SizeMetric.X, SizeMetric.Y), FGraphic);
    hMF := CloseMetaFile(DC);
  if hMF = 0 then
    Result := E_UNEXPECTED;
  // Get memory handle
  if hMem = 0 then
    Result := STG_E_MEDIUMFULL;
  pMFP := PMetafilePict(GlobalLock(hMem));
  pMFP^.hMF := hMF;
  pMFP^.xExt := SizeMetric.X;
  pMFP^.yExt := SizeMetric.Y;

  Medium.tymed := TYMED_MFPICT;
  Medium.hGlobal := hMem;
  Medium.unkForRelease := nil;

  Result := S_OK;

Finally, in TJvCustomRichEdit rename InsertBitmap to InsertGraphic, update the method's parameter from Bitmap: TBitmap to AGraphic: TGraphic, and send AGraphic instead of ABitmap to TImageDataObject.Create.
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
obones (administrator)
2005-02-03 00:41

What's the point of this change?
CCR (reporter)
2005-02-04 20:31

To allow sizeable metafiles (e.g. the clipart one gets with MS Office) to be inserted as sizeable metafiles. As in, copy a metafile to a bitmap first, and when enlarged it will become distorted. Hence, allow it to be inserted directly as itself (so to speak), and the user can then resize it without distortion.

The suggested change also allows the direct insertion of JPEG pictures, of course.
remkobonte (developer)
2005-03-01 13:34

Thanks, this is now in CVS.

- Issue History
Date Modified Username Field Change
2005-02-02 08:11 CCR New Issue
2005-02-03 00:41 obones Note Added: 0006348
2005-02-03 00:41 obones Status new => feedback
2005-02-04 20:31 CCR Note Added: 0006412
2005-03-01 13:34 remkobonte Status feedback => resolved
2005-03-01 13:34 remkobonte Fixed in Version => 3.00
2005-03-01 13:34 remkobonte Resolution open => fixed
2005-03-01 13:34 remkobonte Assigned To => remkobonte
2005-03-01 13:34 remkobonte Note Added: 0006625

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker