473,320 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Gat an image from Clipboard and Save it in tif format

PEB
1,418 Expert 1GB
Hi,

I've managed to copy an image to the clipboard from other application different from Access, but i want to get the image in the clipboard and save it in tif format using Access...

Somewhere i've found a function that loads the image in an Ole field. Is it necessary to do this before saving the image in tif?

Thanks

Vlady
Nov 25 '06 #1
7 6348
NeoPa
32,556 Expert Mod 16PB
Sorry Vlad - I'd help if I knew :(
Nov 26 '06 #2
PEB
1,418 Expert 1GB
Hey Ade,

I've turned the things....

In fact Corel will do the tiff image... I've seen some Macros for it... and the rest is to test them...

I don't want to use them from Access coz i should register new references to libraries... And do my installation more heavy. But i'll run this macros from opened Corel by Access

In plus from Access I have to register more than one reference coz not all types are in one reference

My previous idea was to open the respective Corel Copy it to clipboard and Paste it in ole in Access than transform this Ole to tiff and send the tiff via mail..

But the procedure with pasting in OLE in Access seems a bit long... But using the Corel Macros from Access didn't give me satisfaction!

So the macros should be in Corel and i'll activate them from Access without doing the long procedure of Copy and Paste!

Thanks man! :)
Nov 26 '06 #3
PEB
1,418 Expert 1GB
About pasting an image from clipboard...

it is like:

Expand|Select|Wrap|Line Numbers
  1.         Forms!Link_OLE!OLE1.Action = acOLEPaste
  2.  
Nov 26 '06 #4
PEB
1,418 Expert 1GB
But no function to Save in tif!

I'll search and if i find i'll note here!
Nov 26 '06 #5
PEB
1,418 Expert 1GB
This action needs 4 seconds to be performed...

About pasting an image from clipboard...

it is like:

Expand|Select|Wrap|Line Numbers
  1.         Forms!Link_OLE!OLE1.Action = acOLEPaste
  2.  
Nov 26 '06 #6
PEB
1,418 Expert 1GB
I've found a code to do the conversion.

It's french and i should test it...

http://www.vbfrance.com/code.aspx?ID=5458

Public Class frmConvertionImage
Inherits System.Windows.Forms.Form

Const EOF As Integer = -1

Dim TYPES_IMAGES As String() = {".bmp", ".gif", ".emf", ".jpg", ".png", ".tiff", ".wmf"}
Dim NomFormat As String() = {"Bitmap (BMP)", "Join Phjoto Expert Group (JPG)", "Portable Network Graphic (PNG)", "Tag Image File Format (TIFF)", "Windows Meta File (WMF)", "CompuServ Image (GIF)", "Enhanced Windows (EMF)"}
Dim Compression As String() = {"Aucune", "Très Bonne", "Bonne", "Moyenne", "Faible", "Excellente", "Moyenne"}

Dim strNomFichier As String
Dim strFichierFullPath As String
Dim Extension As String
Dim ConfigFile As String


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim FileInfo As New IO.FileInfo(Application.ExecutablePath)

'Path du fichier de configuration qui contient le dernier type d'image choisi
'ainsi que le dernier choix garder ou pas l'image originale.
ConfigFile = String.Concat(FileInfo.DirectoryName, "\", "Convert.cfg")

'Lecture des arguments, ex: Convert.exe c:\bmp\image.bmp
Dim Command As String() = Environment.GetCommandLineArgs

Dim ioLecture As IO.StreamReader = IO.File.OpenText(ConfigFile)
Dim Choix As Boolean
Dim intSelection As Integer
Dim I As Integer

'Transforme le curseur en petit sablier
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor

'Ajoute tous les noms de format dans la listview
For I = 0 To NomFormat.Length - 1 Step 1
lsvTypesImage.Items.Add(NomFormat(I))
lsvTypesImage.Items(I).SubItems.Add(Compression(I) )
lsvTypesImage.Items(I).ImageIndex = 0
Next I

'Établi l'ordre alphabétique
lsvTypesImage.Sorting = SortOrder.Ascending

'Lit les lignes si la lecture n'est pas rendue a la fin de fichier (EOF)
'Choix Garder/Supprimer
If ioLecture.Peek <> EOF Then
Choix = ioLecture.ReadLine()
Else
Choix = False
End If

'Choix du format précédant
If ioLecture.Peek <> EOF Then
intSelection = CInt(ioLecture.ReadLine())
Else
intSelection = 0
End If

'Fermeture du fichier en lecture
ioLecture.Close()

'Sélectionne la ligne correspondant au format choisi la derniere fois
lsvTypesImage.Items(intSelection).Selected = True

'Coche l'option garder/supprimer choisie la derniere fois
radSupprimer.Checked = Choix
radGarder.Checked = Not Choix

'Si un argument n'a pas été donné lors de l'appel du .exe
If Command.Length = 1 Then

'Restreint l'utilisateur a choisir que ces types de fichiers comme
'fichier a convertir
OpenFileDialog1.Filter = "Tous les types d'images suppotés|*.bmp;*.gif;*.emf;*.jpg;*.jpeg;*.png;*.ti ff;*.wmf|Bitmap (BMP)|*.bmp|CompuServ Image (GIF)|*.gif|Enhanced Windows (EMF)|*.emf|Join Phjoto Expert Group (JPG)|*.jpg;*.jpeg|Portable Network Graphic (PNG)|*.png|Tag Image File Format (TIFF)|*.tiff|Windows Meta File (WMF)|*.wmf"

'Ouvre la fenetre d'ouverture de fichier
OpenFileDialog1.ShowDialog()

'Saisie du nom de fichier
strFichierFullPath = OpenFileDialog1.FileName()

'Si aucun fichier n'a été sélectionnée, Fin du programme
If strFichierFullPath = String.Empty Then
Me.Close()
Exit Sub
End If

Else

'Si un argument a été donnée, cet argument est le fichier a convertir
strFichierFullPath = Command(1)

End If

'Sert a obtenir des information sur le fichier
Dim FileInfo2 As New IO.FileInfo(strFichierFullPath)

Extension = FileInfo2.Extension
strNomFichier = FileInfo2.Name

lblNom.Text = String.Concat("Nom de l'image à convertir : ", strNomFichier)

'Rétabli le curseur de Windows par défault
Me.Cursor = System.Windows.Forms.Cursors.Default

End Sub


Private Sub btnAnnuler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnnuler.Click
'Fermeture du programme
Me.Close()
End Sub


Private Sub Convertir()

'Si un item a été sélectionné
If lsvTypesImage.SelectedIndices.Count > 0 Then

'Curseur Sablier
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor

'Sauvegarde des options (Types de fichier et Garder/Supprimer)
Dim ioEcriture As IO.StreamWriter = IO.File.CreateText(ConfigFile)
ioEcriture.WriteLine(radSupprimer.Checked)
ioEcriture.WriteLine(lsvTypesImage.SelectedIndices (0))
ioEcriture.WriteLine("caca")
ioEcriture.Close()


Dim Convertisseur As New System.Drawing.Bitmap(strFichierFullPath)
Dim NouvelleExtension As String = TYPES_IMAGES(lsvTypesImage.SelectedIndices(0))
Dim strNouveauFichier As String = String.Concat(strNomFichier.Substring(0, strNomFichier.LastIndexOf(".")), NouvelleExtension)

'Vérification si le ficheir existe déja
If NouvelleExtension = Extension Or IO.File.Exists(strNouveauFichier) Then
MsgBox("Le fichier existe déjà. Choissisez un autre format d'image.", MsgBoxStyle.Critical, "Erreure lors de la création du fichier.")
Me.Cursor = System.Windows.Forms.Cursors.Default

'Si le fichier existe déja, la procédure ne se poursuit pas
Exit Sub
End If

'Converti le fichier en un autre format selon l'extension cible
Select Case NouvelleExtension
Case ".jpg"
Convertisseur.Save(strNouveauFichier, System.Drawing.Imaging.ImageFormat.Jpeg)
Case ".tiff"
Convertisseur.Save(strNouveauFichier, System.Drawing.Imaging.ImageFormat.Tiff)
Case ".wmf"
Convertisseur.Save(strNouveauFichier, System.Drawing.Imaging.ImageFormat.Wmf)
Case ".gif"
Convertisseur.Save(strNouveauFichier, System.Drawing.Imaging.ImageFormat.Gif)
Case ".png"
Convertisseur.Save(strNouveauFichier, System.Drawing.Imaging.ImageFormat.Png)
Case ".bmp"
Convertisseur.Save(strNouveauFichier, System.Drawing.Imaging.ImageFormat.Bmp)
Case ".emf"
Convertisseur.Save(strNouveauFichier, System.Drawing.Imaging.ImageFormat.Emf)
End Select

'Libère les ressources utilisées par Convertisseur
Convertisseur.Dispose()

'Supprime l'image originale si l'option de la supprimer est activée
If radSupprimer.Checked Then
Kill(strFichierFullPath)
End If


End If
btnAppliquer.Enabled = False
'Rétabli le curseur
Me.Cursor = System.Windows.Forms.Cursors.Default

End Sub

Private Sub lsvTypesImage_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lsvTypesImage.DoubleClick
Convertir()
End Sub

Private Sub btnOk_CLick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Convertir()
Me.Close()
End Sub

Private Sub lsvTypesImage_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lsvTypesImage.SelectedIndexChanged
btnAppliquer.Enabled = True
End Sub

Private Sub btnAppliquer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAppliquer.Click
Convertir()
End Sub
End Class



Explication finaleSi vous voulez, vous pouvez compiler le setup qui vient avec le projet et si vous l'installez, vous aurez un item ajouté au menu contextuel qui s'affiche lorsque vous cliquez sur le bouton de droit sur une image. Vous pourrez alors
convertir vos images comme si cette fonction serait intégrée dans Windows.

Note : Convert.cfg doit etre dans le répertoire de l'éxécutable (J'aurais pu arranger ca...)

C'est mon premier projet VB.NET qui sert a quelque chose, alors soyez un peu indulgents.

Nov 26 '06 #7
PEB
1,418 Expert 1GB
In fact i've not managed to start the sub convertisseur work properly...

I've tried with Createobject("Imaging.Application")
With GetObject(FileName)

But not of them produced the wanted result of convertion!


If someone knows about the object class of pbrush or paint...
Nov 26 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a...
2
by: Gey-Hong Gweon | last post by:
Is there a way to copy a PIL image to windows clipboard (as a dib image or a bitmap, I suppose)? What I would like to accomplish is to do a fast copy and paste of images from my python...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
15
by: Lou | last post by:
How do I get the data in the clipbaord fro a registered data type. The code snippet below doesn't work? But the VB6 example does. What am I doing wrong. private void lstItems_DragDrop(object...
2
by: Mészáros Tamás | last post by:
Hi! Can I save and restore the content of the clipboard without dealing with the format it stores? I use the clipboard for data exchange between applications (this is the only way), and I would...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
5
by: exhuma.twn | last post by:
As many might know, windows allows to copy an image into the clipboard by pressing the "Print Screen" button on the keyboard. Is it possible to paste such an image from the clipboard into a "Text"...
6
by: Jerry Spence1 | last post by:
I am using a network camera that saves the image in a byte array in memory (via their ocx component, and in the OnNewImage event I can get the pointer to the image and the byte length as...
1
by: nikhilkajrekar | last post by:
i have picturedata and i want to save that to image file how i can do that i have this function but not working for all images Function FPictureDataToClipBoard(ctl As Variant) As Boolean '...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.