BLOB

ODBC

Модератор: Andrew™

Правила форума
При написании вопроса или обсуждении проблемы, не забывайте указывать версию Clarion который Вы используете.
А так же пользуйтесь спец. тегами при вставке исходников!!!
Ответить
gromov
Старожил
Сообщения: 263
Зарегистрирован: 11 Февраль 2009, 8:41
Откуда: г. Анапа
Поблагодарили: 3 раза

BLOB

Сообщение gromov »

Переползая с MAV на ODBC наткнулся на очередные грабли. Есть таблица с полем BLOB. Это картинка, которую нужно достать и поместить в отчет. Казалось бы, что проще BlobToFile и все Ок.
Увы. На выходе имею нечитабельный JPG. IBExpert показывает размер блоба, скажем 13611, SELECT CHAR_LENGTH(Blob) FROM Table то же самое. Кларин SIZE – ровно в два раза больше. Проверял на нескольких блобах. И файл, куда выгружаю картинку имеет такой же размер. Что сие означает ?
kreator
✯ Ветеран ✯
Сообщения: 4960
Зарегистрирован: 28 Май 2009, 15:54
Откуда: Москва
Благодарил (а): 6 раз
Поблагодарили: 19 раз

BLOB

Сообщение kreator »

prop:ImageBits работает точно.
Memo and Blob variables are capable of storing large variable length chunks of binary data. This makes them suitable for storing graphic images. MEMOs are limited to 64K or less. BLOBS have no size limit. Storing and displaying images with Memo or Blob variables requires the following:

Storing Graphic Images in BLOBs or MEMOs
To store the graphic image into the MEMO or BLOB variable, channel it through an IMAGE control.
That is, assume the image resides in C:\IMAGES\IMAGE.BMP. We need to transfer the .BMP file to a CW IMAGE control, then transfer from the IMAGE control to the MEMO or BLOB variable.
1.The BLOB or MEMO variable must have the BINARY attribute.
In the Data Dictionary, use the Field Properties dialog's General tab to set the Data Type to MEMO or BLOB, then check the Binary box.
2.Assign the image file to an IMAGE control.
In the Image Properties dialog, in the File field, use the ellipsis (...) button to name the file containing the graphic image.
or
Assign the file name with Clarion's property syntax as follows:
?Image1{PROP:Text} = filename
3.Transfer the image from the IMAGE control to the MEMO or BLOB variable using Clarion's property syntax:
For MEMOs:
CON:TheMemo = ?Image1{PROP:ImageBits}
For BLOBs:
CON:TheBlob{PROP:Handle} = ?Image1{PROP:ImageBlob}

Displaying Graphic Images from BLOBs or MEMOs

To restore (ie display) the image from a BLOB or MEMO to an IMAGE control, you must properly define the size of the IMAGE control. The IMAGE control must either be of Default size, or of a fixed size set after the MEMO or BLOB data is assigned to it.
1.To set the IMAGE control to default size.
In the Image Properties dialog, on the Position tab, check the Default boxes for Height and Width.
2.Use Clarion's property syntax to transfer the MEMO or BLOB data to the IMAGE control.
For MEMOs:
?Image2{PROP:ImageBits} = CON:TheMemo
For BLOBs:
?Image2{PROP:ImageBlob} = CON:TheBlob{PROP:Handle}
3.After the MEMO or BLOB has been assigned to the IMAGE with property syntax, a fixed width and height may be assigned to the IMAGE Control:
?Image2{PROP:Width} = 92
?Image2{PROP:Height} = 88

The shipping SCHOOL example demonstrates using property assignments for images.
We are hard at work… for you. :)
gromov
Старожил
Сообщения: 263
Зарегистрирован: 11 Февраль 2009, 8:41
Откуда: г. Анапа
Поблагодарили: 3 раза

BLOB

Сообщение gromov »

Спасибо. Оказывается флажок "Binary" в словаре очень актуальная вещь. :D
Yufil
Ветеран движения
Сообщения: 1277
Зарегистрирован: 16 Май 2006, 14:34
Контактная информация:

BLOB

Сообщение Yufil »

Добрый вечер!
Для работы с картинками в Blob надо использовать параметр Prop:PrintMode
Если установлен этот параметр, в базу можно записать сам файл ( jpg, Gif, Png ) без каких бы то ни было преобразований,
после чего можно записать запись с блобом в базу.

Для показа надо достать запись и выполнить

?Image{Prop:PrintMode}=3
?Image{Prop:ImageBlob} = BlobField{Prop:Handle }
Ответить