PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
Go Back  Xtreme Visual Basic Talk > > > > PowerPoint – Programmaically Editing Bitmapped Images


Reply
 
Thread Tools Display Modes
  #1  
Old 09-22-2015, 07:43 PM
NedPi NedPi is offline
Newcomer
 
Join Date: Mar 2015
Posts: 1
Default PowerPoint – Programmaically Editing Bitmapped Images


This may be a bridge too far for Microsoft Office, but it would sure be convenient it could do something like this ...

I'm looking for a way to edit bitmapped images programmatically – that is to read in images, extract rectangular regions of pixels and insert them into another image. I've not seen any documentation to indicate that it is possible to paste rectangular regions of pixels from one image into an arbitrary portion of another image but that's what I'm looking for.

Any help would be much appreciated.

Best,
-Ned

Code:
Sub TEST() 
 
Dim oPic1 As Shape, oPic2 As Shape 
Dim oSlide As Slide 
Dim FullPath As String 
Dim a_width As Long, a_height As Long 
 
' Set slide 
Set oSlide = Application.ActiveWindow.View.Slide 
 
' Read in source image 
FullPath = "C:\Users\Ned\TEST_01.png" 
Set oPic1 = oSlide.Shapes.AddPicture(FileName:=FullPath, _ 
                LinkToFile:=msoFalse, _ 
                SaveWithDocument:=msoTrue, _ 
                Left:=0, Top:=0, _ 
                Width:=-1, Height:=-1) 
 
a_width = oPic1.Width 
a_height = oPic1.Height 
 
' Create destination image 
Set oPic2 = oSlide.Shapes.AddShape(Type:=msoShapeRectangle, _ 
    Left:=0, Top:=0, Width:=500, Height:=500) 
 
' Assume:  source image is 805x828 pixels 
'          destination image is 500x500 pixels 
'          transfer rectangle: TopLeft: 207,10 BottomRight: 598,35 
'          (origin is UpperLeft) 
'          place in destination image: TopLeft: 20,30 BottomRight: 411,55 
 
' Copy from source 
oPic1.Copy 
With oPic1 
    .LockAspectRatio = msoFalse 
    .PictureFormat.CropLeft = (207 / 805) * 525 
    .PictureFormat.CropRight = (207 / 805) * 525 
    .PictureFormat.CropTop = (10 / 828) * 540 
    .PictureFormat.CropBottom = (793 / 828) * 540 
End With 
' This does not work but it's the preferred approach.  The above 
' works but requires re-reading the image if there are multiple 
' regions to copy. 
'With oPic1.Copy 
'    .Top = 10 
'    .Left = 207 
'    .Width = 598 - 207 
'    .Height = 35 - 10 
'End With 
 
' Paste to destination 
' This does not work either - and is the detail that dooms this 
' approach. 
'With oPic2.PasteSpecial 
'    .Top = 30 
'    .Left = 20 
'    .Width = 598 - 207 
'    .Height = 35 - 10 
'End With 
 
' <Eventually other copy/paste operations to destination image> 
 
' Write destination image to file 
FullPath = "C:\Users\Ned\TEST_02.png" 
oPic2.Export FullPath, ppShapeFormatPNG 
 
End Sub
Reply With Quote
Reply

Tags
image, destination, fullpath, pixels, set, dim, opic1, images, source, shape, .pictureformat.cropbottom, top=0, left=0, .pictureformat.cropleft, opic1.copy, topleft, copy, .pictureformat.cropright, slide, oslide, a_width, a_height, .pictureformat.croptop, opic2, paste


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
 
PowerPoint – Programmaically Editing Bitmapped Images
PowerPoint – Programmaically Editing Bitmapped Images
 
-->